How to convert a WordPress mysql DB to UTF8?

I’ve had my self hosted WordPress blog for a long time. I just realized that my DB is not UTF8 and certain plugins won’t work correctly.

My question is this. How does a very novice mysql’er go about converting my database? As you can imagine, I’m very hesitant to do this on my own as I have 5 years worth of posts I don’t want to jack up.

Read More

Can anyone point me in the right direction, or even better step me through the process for converting everything to UTF8?

Related posts

Leave a Reply

1 comment

  1. After backing up your database as Konerak said, run this for every table:

    ALTER TABLE tablename CONVERT TO CHARACTER SET utf8;
    

    (you may want to check with SHOW FULL COLUMNS FROM tablename whether all (text)columns are now indeed corrrect)

    And right after you connect to MySQL, run the query:

    SET NAMES utf8;
    

    Now, to tell your audience you are using utf8: you could craft a custom header in every page or in an always included file, I however find it easier to put this in an .htaccess for Apache in the root:

    php_value default_charset "UTF-8"
    

    If you have non-ASCII content in flat files instead of only in the database, you’ll have to convert them too. Your favorite editor may have a batch convert tool, or you can use iconv.