Wednesday, June 10, 2009

New Hosting Provider, mysql & Wordpress Unicode Issues

Hi folks!

Just a quick note - I've moved to a new hosting provider. If you see anything wonky, broken links, or other such weirdness shoot me an email.

When I first migrated the database (a few days ago) I ended up with some spurious Unicode characters scattered throughout the website. (E.g. lots of strange à characters stuck in around words, &etc.) Turns out the problem was mysql. Wordpress was correctly backing up the database as utf8, but when I re-imported it, it was re-encoding it for some reason. The solution was to add "--default_character_set=utf8" on the mysql command line during the database restore/import.

E.g.:

# mysql --default_character_set=utf8 -u{username} -p{password} {dbname} -h {hostname} < db-backup-file.sql


Deleting and re-importing the database with the --default_character_set option fixed it right up! (I'm posting this as a reminder to myself as well.)

Cheers!
- K.C.

2 comments: