Convert MySQL table to utf8

Read here how to change all your DB to utf8, pretty simple, but you gotta know it. Even when your app runs in latin1 only, it reduces a couple problems in case you forgot some check and utf8 is slipping through. I will let you know if I can prove that right. But since Django is trying to be unicode compliant, it’s easier to use it than to work around it.
It does at least already eliminate the problem of getting this error:

Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)

this was discussed here.
In short:

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

6 Comments »

  1. Mike said,

    February 28, 2009 at 4:21 am

    Thanks for posting this!

    I change this so seldom that by the time I need to do it again I’ve forgotten how!

  2. MySQL + UTF-8 = Not So Obvious « Ward’s Words said,

    March 28, 2009 at 9:56 am

    [...] existing literature on the topic including possible fixes [here, here, here, here, here, here, horror story here, here] encourage the configuration of the MySQL daemon [...]

  3. Carolina said,

    August 20, 2009 at 10:40 am

    Hello,
    I have a question. This command that was written by Wolfram only modifies the charset from the table… But not all string datatypes from the table. Those remained without been changed… Is there a way to alter the table recursively, so that all string datatypes from the table will be also modified to utf8?

    Thank you very much!

  4. online stock trading guru said,

    January 11, 2010 at 5:39 am

    Super-Duper site! I am loving it!! Will come back again - taking your feeds too now, Thanks.

    I’m Out! :)

  5. Normaderm said,

    January 20, 2010 at 10:54 am

    thank ^ ^

  6. Mobiel Abonnement said,

    May 25, 2010 at 11:03 am

    Thank :) it helpt me to convert my database

RSS feed for comments on this post · TrackBack URL

Leave a Comment