I am trying to migrate a WordPress site from one server to another, but on the new server I'm getting incorrect symbols in place of UTF8 (I assume) characters.

I dumped the database using mysqldump:

mysqldump mydb -r /var/www/vhosts/mysite/database.sql

I then sent it to the new server using rsync:

rsync -r -a -v -e ssh --delete --no-perms --omit-dir-times /var/www/vhosts/mysite user@targetserver:/var/www/vhosts/

I then created a new DB on the new server:

GRANT ALL privileges ON wpdb.* TO "wp"@"%" IDENTIFIED BY "password";
FLUSH privileges;

And then imported the data:

SET names 'utf8mb4';
SOURCE /var/www/vhosts/mysite/database.sql;

If I use the mysql client to pull out some sample posts, I see the correct symbols. If I look at the SHOW CREATE for the posts table at both ends, they both show


I don't know how else to ensure UTF8 throughout the pipeline.

I have compared various stages of the process. For example, if I look at the database.sql dump at both ends for an offending piece of text, I see:

 pages we can tell you who’s ready

On both sides, so I don't think it's mysqldump or the rsync.

I then look in the database by simply using the mysql client and querying the posts table:

pages we can tell you who’s ready 

So it seems to have ended up in the DB okay.

On-screen though:

pages we can tell you who�s ready

Could it be a PHP setting?

migrated from serverfault.com Aug 4 '15 at 16:34

This question came from our site for system and network administrators.

  • Seems I got migrated. I didn't even think of looking for a WP.SE :) – Cylindric Aug 5 '15 at 9:12
  • it is because the utf8mb4 is an extended set of characters. Your MySQL will probably only have the utf8 set installed and not the extended set so characters will go missing or not match when you import. – Alex Older Aug 5 '15 at 10:38
  • Would that not show when I tried to set names or in the show create though? – Cylindric Aug 5 '15 at 13:43
  • It would cause any number of problems when you're trying to set UTF8 characters is a UTF8mb4 setting – Alex Older Aug 6 '15 at 8:45
  • What I mean is, if I try to create a table with the utf8mb4 charset on a server without it, I'd expect an error. – Cylindric Aug 12 '15 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.