一、查找my.conf的位置
[root@dcm-no zookeeper]# whereis my.cnf
my: /etc/my.cnf
[root@dcm-no zookeeper]#
1
2
3
二、在[mysql]和[mysqld]标签下分别增加(修改)以下内容
vim /etc/my.cnf
[mysql]
default-character-set = utf8
[mysqld]
character_set_server = utf8
三、重启数据库
[root@dcm-no zookeeper]# service mysql restart
Redirecting to /bin/systemctl restart mysql.service
[root@dcm-no zookeeper]#
四、验证编码是否改变
进入数据库查询:show variables like ‘%char%’;
查询结果:
character_set_database和character_set_server的值都为utf8
(责任编辑:IT) |