[root@kvm3 ~]# cat /etc/my.cnf # # This group is read both both by the client and the server # use it for options that affect everything # [client-server] # # include all files from the config directory # !includedir /etc/my.cnf.d
[root@kvm3 ~]# ll /etc/my.cnf.d/ total 24 -rw-r--r--. 1 root root 42 Aug 9 2022 auth_gssapi.cnf -rw-r--r--. 1 root root 295 Apr 12 2022 client.cnf -rw-r--r--. 1 root root 763 May 18 2022 enable_encryption.preset -rw-r--r--. 1 root root 1458 Aug 9 2022 mariadb-server.cnf -rw-r--r--. 1 root root 232 May 18 2022 mysql-clients.cnf -rw-r--r--. 1 root root 120 May 18 2022 spider.cnf
[root@kvm3 ~]# mariadb -s -uroot -p123qwe -e "show variables like '%character%'" Variable_name Value character_set_client utf8 character_set_connection utf8 character_set_database latin1 character_set_filesystem binary character_set_results utf8 character_set_server latin1 character_set_system utf8 character_sets_dir /usr/share/mariadb/charsets/
latin1_swedish_ci
。
[root@kvm3 ~]# mariadb -s -uroot -p123qwe -e "show variables like '%collation%'" Variable_name Value collation_connection utf8_general_ci collation_database latin1_swedish_ci collation_server latin1_swedish_ci
[root@kvm3 ~]# vim /etc/my.cnf.d/mariadb-server.cnf [root@kvm3 ~]# grep '^\[mariadb\]' -A2 /etc/my.cnf.d/mariadb-server.cnf [mariadb] collation-server=utf8_general_ci character-set-server=utf8
[root@kvm3 ~]# systemctl restart mariadb.service
[root@kvm3 ~]# systemctl restart mariadb.service [root@kvm3 ~]# mariadb -s -uroot -p123qwe -e "show variables like '%character%'" Variable_name Value character_set_client utf8 character_set_connection utf8 character_set_database utf8 character_set_filesystem binary character_set_results utf8 character_set_server utf8 character_set_system utf8 character_sets_dir /usr/share/mariadb/charsets/
utf8_general_ci
了。
[root@kvm3 ~]# mariadb -s -uroot -p123qwe -e "show variables like '%collation%'" Variable_name Value collation_connection utf8_general_ci collation_database utf8_general_ci collation_server utf8_general_ci