如何将“ collat​​ion_connection”永久设置为utf8mb4_unicode_ci?

时间:2019-12-12 10:24:16

标签: mysql

我对my.cnf进行了更改,以使用 utf8mb4 utf8mb4_unicode_ci

[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect = 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'
init-connect = 'SET collation_connection = utf8mb4_unicode_ci'

但是,当我跑步时:

SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

这是回应。

+--------------------------+--------------------+
| Variable_name            | Value              |
+--------------------------+--------------------+
| character_set_client     | utf8mb4            |
| character_set_connection | utf8mb4            |
| character_set_database   | utf8mb4            |
| character_set_filesystem | binary             |
| character_set_results    | utf8mb4            |
| character_set_server     | utf8mb4            |
| character_set_system     | utf8               |
| collation_connection     | utf8mb4_general_ci |
| collation_database       | utf8mb4_unicode_ci |
| collation_server         | utf8mb4_unicode_ci |
+--------------------------+--------------------+

如您所见,collat​​ion_connection是 utf8mb4_general_ci ,但我希望它是 utf8mb4_unicode_ci

目前,唯一的解决方法是让我运行:

SET collation_connection = utf8mb4_unicode_ci

但是,一旦MySQL服务器重新启动,它就会恢复为 utf8mb4_general_ci

是否存在将归类连接设置为 utf8mb4_unicode_ci 的永久方法?

0 个答案:

没有答案