Skip to content

Instantly share code, notes, and snippets.

@khanhicetea
Created November 16, 2015 11:18
Show Gist options
  • Save khanhicetea/785b77d5e9222f231902 to your computer and use it in GitHub Desktop.
Save khanhicetea/785b77d5e9222f231902 to your computer and use it in GitHub Desktop.
MySQL changing to UTF8
-- Ref : http://stackoverflow.com/a/19301922
SELECT CONCAT("ALTER TABLE `",TABLE_SCHEMA,"`.`",TABLE_NAME,"` CHARACTER SET utf8 COLLATE utf8_unicode_ci;",
"ALTER TABLE `",TABLE_SCHEMA,"`.`",TABLE_NAME,"` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;")
AS `alter_sql`
FROM `information_schema`.TABLES
WHERE TABLE_SCHEMA = 'db_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment