Converted the WordPress database to UTF-8

I just converted the WordPress database to UTF-8. It turned out when I create a database on my hosting website it defaults to latin1. The conversion was pretty easy in just a few steps.

These are the steps I took.

  1. Export the database. I used phpMyadmin and just ran an export to a file name mine.sql
  2. To convert the data in the database I ran : iconv -f ISO-8859-1 -t utf8 mine.sql > mine-utf8.sql
  3. (iconv was installed on my Linux box)

  4. Opened the mine-utf8.sql in VI and ran: %s/CHARSET=latin1/CHARSET=utf8/
  5. Created a new database with the UTF-8 settings.
  6. Added the appropriate rights for the new database to the existing MySQL user I use for WordPress.
  7. Imported the data int the new database using the mine-utf8.sql file.
  8. Changed wp-config.php to use the new database.

And that was it.

Of course you could drop the existing database and create it as UTF-8 but I rather had a security in case the conversion didn’t work.

This article is filed under the categories This Website » WordPress and has the following tags associated with it: , , , , , , .