1、創建批量修改語句
修改單個表的字符集的命令是:alter table 表名 convert to character set utf8mb4 collate utf8mb4_bin;
創建修改語句的命令是:
select CONCAT('alter table ',a.table_name,' convert to character set utf8mb4 collate utf8mb4_bin;') from (select table_name from information_schema.`TABLES` where TABLE_SCHEMA = '這里寫數據庫的名字其他地方不用改') a;
執行完了以后會得到下面的結果:
2、批量修改
將上面的語句批量復制,然后全部執行。
我用的客戶端工具是navicat。其它如workbench等隨便一個都可以的,甚至命令行也是可以的