MySQL Forums
Forum List  »  General

Re: Converting Latin1 to UTF8
Posted by: Tom Wardrop
Date: October 02, 2013 07:00PM

Ok, with the help of "kolbe", a helpful sole on IRC, this is what ended up doing the trick...

mysqldump --opt --default-character-set=latin1 <database> | replace latin1 utf8 | mysql --default-character-set=utf8 <new_database>

The clue that 'kolbe' gave rise to was the `SET NAME latin1` at the top of the dump. My `replace` command previous looked for "CHARSET=latin1", instead of just "latin1", hence on import, despite setting --default-character-set=utf8, the "SET NAME latin1" line the output was always overriding it, messing up all my UTF8-encoded characters.

I do believe MySQL should provide a way to change the character sets of tables and columns WITHOUT actually converting the data. The "to blob" method just isn't practical in the real-world; it's cumbersome, doesn't work with foreign keys or indexes, etc.

I also recommend everyone read this: http://dev.mysql.com/doc/refman/5.6/en/comments.html

Who knew those "comments" in the mysqldump output weren't actually comments.



Edited 1 time(s). Last edit at 10/02/2013 07:03PM by Tom Wardrop.

Options: ReplyQuote


Subject
Written By
Posted
October 02, 2013 06:03PM
Re: Converting Latin1 to UTF8
October 02, 2013 07:00PM
October 03, 2013 08:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.