批量设置mysql表编码

一片枫树叶小于 1 分钟数据库MySQL

批量设置mysql表编码

生成修改的代码

SELECT CONCAT('ALTER TABLE ', table_name, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;') FROM information_schema.TABLES WHERE TABLE_SCHEMA = '数据库名称' 

执行修改的代码

ALTER TABLE business_xx1 CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

ALTER TABLE business_xx2 CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;