MySQL 4 to MySQL 5 Character Sets and Collation

Moving from MySQL 4 to MySQL 5 caused a few issues on Joomla websites. The problems stem from MySQL 4 using latin1 swedish as default but some applications like Joomla want utf8 so:

1. Re-export the database (it is Ok to do this from the existing MySQL 5 database):

mysqldump -u username -p –default-character-set=latin1 –compatible=mysql40 dbname > dump.sql

2. Import the database again (overwriting the current oddly encoded tables – you do have a backup right!) :

mysql -u username -p –default-character-set=utf8 dbname < dump.sql

Note: It is not enough to just convert the database / tables with:

ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Although this will convert the database defaults it does not perform the conversion from latin1 to utf8 on the existing actual content.

Leave a Reply

  • (will not be published)

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