What to do if WordPress is not displaying UTF-8 correctly?

Published on March 25, 2010

A while ago, this blog was not showing correctly some chinese (UTF-8) characters.

It was due to the WordPress that I have set up using a wrong character set. It was using latin1 instead of UTF-8.

To solve the problem, you could go to phpMyAdmin, and run the following SQLs.
Note: Change wrdp1 to your wordpress database name accordingly.

ALTER TABLE wrdp1.wp_comments CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_links CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_options CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_postmeta CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_posts CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_terms CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_term_relationships CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_term_taxonomy CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_usermeta CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE wrdp1.wp_users CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

phpmyadmin

The result should be like the table above.

But note that we are not able to recover any UTF-8 characters that were in a post before this operation. You would need to edit the post, enter the correct UTF-8, and save.