[Tip] Moving wordpress DB with unicode content

Recently, I migrated my home server to DH, and after transferring the wordpress database from MySQL V4.1 to V5.0, all chinese content was displayed as ?? on the webpage. With a little search, you could find the solutions in wordpress support pages, but information are sparse; So, I summarise the solution here:

  1. Firstly, ensure the wordpress database and its table are showing [color=#CC0000]unicode_general_ci[/color] in [color=#0000CC]collation[/color] field. Mine was already set while restoring from the database dump.
  2. Go to your wordpress directory wp-include/wp-db.php, after this line:

$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);Add this:

$this->query("SET NAMES UTF8");That’s it.
my blog on the subject

Thanks for sharing that excellent tip. I’m sure it will be of use to many users. :slight_smile: