我正在连接到配置为使用utf8mb4编码并忽略客户端设置的编码的MySQL服务器(v5.7.21)。以下是my.ini配置文件的相关部分(我正在运行Windows):
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
character-set-client-handshake=FALSE
skip-character-set-client-handshake #I've added this but it has no effect
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
我的客户端是一个使用JDBC驱动程序的ETL(Talend):mysql-connector-java-5.1.30-bin.jar
如果我设置了驱动程序属性:characterEncoding=utf8
,则会覆盖服务器设置的字符编码(utf8mb4),如此查询所示:
SHOW VARIABLES
WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'
|=-----------------------+-----------------=|
|Variable_Name |Value |
|=-----------------------+-----------------=|
|character_set_client |utf8 |
|character_set_connection|utf8 |
|character_set_database |utf8mb4 |
|character_set_filesystem|binary |
|character_set_results | |
|character_set_server |utf8mb4 |
|character_set_system |utf8 |
|collation_connection |utf8_general_ci |
|collation_database |utf8mb4_unicode_ci|
|collation_server |utf8mb4_unicode_ci|
'------------------------+------------------'
如果我没有在连接上设置任何驱动程序属性,则使用utf8mb4编码(这是预期的)。
似乎设置character-set-client-handshake=FALSE
和skip-character-set-client-handshake
没有效果
如何防止客户端更改编码并强制它始终使用utf8mb4?