Dec 232007

Again on WP migration.

My previous 2.0.11 installation was having DB collation and Character Set configured as latin1 (by default with WordPress 2.0.x).

Bad thing happened when I exported my sql db and reimported in new 2.3.1 installation (defaulting at UTF-8) and saw all accented characters displayed as question marks, ugly signs, etc. 🙁

I also tried exporting as UTF-8 in WP 2.0, but soon realized that WP 2.0.x does not include support for UTF-8 Character Set.

Found a solution in a blog, and reporting it here to avoid spending again two days in future Googling… and testing.

MySQL Export command from WordPress 2.0.11:

mysqldump -a –add-drop-table –databases -u <username with privileges> -p <database_name> > <filename>.sql

MySQL Import command on WordPress 2.3.1 box:

cat <filename>.sql | mysql –default-character-set=utf8 -u <username with privileges> -p <database_name>

Also. remember to check for presence in your wp-config.php of two very important lines:

define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);

Especially the first line: if it’s missing, WordPress will still display ugly characters even if in tables they are properly formatted.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>