UTF-8ify an existing MySQL database

Posted Over 13 years ago. Visible to the public.

First do

ALTER DATABASE database_name CHARACTER SET "utf8";
ALTER DATABASE database_name COLLATE "utf8_unicode_ci";

After that, for each table:

ALTER TABLE table_name DEFAULT CHARACTER SET "utf8" COLLATE "utf8_unicode_ci";

This just changes the default character set / collation for each table. To convert them, you need:

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Henning Koch
Last edit
Almost 10 years ago
Keywords
utf8, mysql
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-08-26 20:34)