Skip to content

Instantly share code, notes, and snippets.

@unpluggedcoder
Created February 11, 2018 03:09
Show Gist options
  • Save unpluggedcoder/c151b5b4ae6f814cc602f423e5c64c92 to your computer and use it in GitHub Desktop.
Save unpluggedcoder/c151b5b4ae6f814cc602f423e5c64c92 to your computer and use it in GitHub Desktop.
[MySQL CONVERT CHARACTER SET to utf8 for all tables] Generate query for convert character set to utf8 for all tables #mysql #characterset
SELECT CONCAT("ALTER TABLE `", TABLE_NAME,"` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;") AS ExecuteTheString
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="[YOUR DATABASE NAME]"
AND TABLE_TYPE="BASE TABLE";
SELECT @@character_set_database, @@collation_database;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment