起因
一个原来跑在 Mysql 5.7上的应用,升级到 Mysql 8.0.29后,提示
Character set 'utf8mb3' is not supported by .Net Framework
环境
开发环境:VS2019/ .net Framework 4.6
调试环境:Windows 11
数据库:CentOS 7.6 / Mysql 8.0.29
中间件:Mysql.Data 8.0.22
问题根源
Historically, MySQL has used utf8 as an alias for utf8mb3; beginning with MySQL 8.0.28, utf8mb3 is used exclusively in the output of SHOW statements and in Information Schema tables when this character set is meant.
At some point in the future utf8 is expected to become a reference to utf8mb4. To avoid ambiguity about the meaning of utf8, consider specifying utf8mb4 explicitly for character set references instead of utf8.
You should also be aware that the utf8mb3 character set is deprecated and you should expect it to be removed in a future MySQL release. Please use utf8mb4 instead.
解决
1、修改连接字符串,明确指定字符集 utf8mb4
2、修改建表语句,明确指定字符集 utf8mb4
,此处通过vim
批量替换%s/CHARSET=utf8;/CHARSET=utf8mb4;/g