
本文主要介绍了MySQL8 批量修改字符集脚本,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
从低版本迁移到MySQL 8后,可能由于字符集问题出现 Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) 错误,此时要修改对象的字符集。
1. 批量修改库字符集
change_database_characset.sql
1 2 3 4 |
select concat( 'alter database ' ,schema_name, ' default character set utf8mb4 collate utf8mb4_0900_ai_ci;' ) from information_schema.schemata where schema_name not in ( 'sys' , 'mysql' , 'performance_schema' , 'information_schema' ) and lower (default_collation_name) in ( 'utf8mb4_general_ci' , 'utf8_general_ci' ); |