Converting MySQL data to UTF-8

I decided to convert my blog to use UTF-8 rather than Latin-1 as its character set, this turned out to be somewhat of a PITA. After changing all the table and database character sets manually I had to convert the data. Eventually settling for this little terminal magic.

mysqldump --default-character-set=latin1 --add-drop-table cs278_blog | sed 's/SET NAMES latin1/SET NAMES utf8/' | mysql cs278_blog

I redumped the data afterwards and checked it over with iconv which found nothing to complain about. I found how to do this here.

Leave a Reply