Wednesday, August 1, 2012

MySQL: Change Collation on an Existing Table

I recently ran across an issue where a table's collation was set to latin1_swedish_ci and it really should have been utf8_unicode_ci. Just changing the collation didn't seem to be doing the trick because some characters were still messed up. That's when I realized you need to convert the current character set to UTF8. After doing this everything worked as expected.

ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci

1 comment: