Mysql Alter Collation In All Tables And Columns

less than 1 minute read

This process can be easily done from PhpMyAdmin.

  1. In query below, change ‘database_name’ with your actual database name
  2. Run the query
  3. The queries you need to change the collation of all tables will be printed as a result. Copy the queries
  4. Run the queries
  5. Pet your cat (This step is optional)
SELECT CONCAT('ALTER TABLE `', t.`TABLE_SCHEMA`, '`.`', t.`TABLE_NAME`,
 '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') as stmt 
FROM `information_schema`.`TABLES` t
WHERE 1
AND t.`TABLE_SCHEMA` = 'database_name'
ORDER BY 1

Updated:

Leave a comment