Skip to content

Instantly share code, notes, and snippets.

@kitzberger
Last active September 18, 2018 12:34
Show Gist options
  • Save kitzberger/08dd20ae8b9de333d3c444d3efa76fd4 to your computer and use it in GitHub Desktop.
Save kitzberger/08dd20ae8b9de333d3c444d3efa76fd4 to your computer and use it in GitHub Desktop.
-- Find out what charset and collation the DB has:
SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation'
FROM information_schema.SCHEMATA;
-- Find out what charset and collation the tables have:
SELECT T.table_name, CCSA.character_set_name, CCSA.collation_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
-- Change charset and collation of DB:
ALTER DATABASE some_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment