Centos7设置utf8编码:
1.mysql -u root -p登录mysql,然后
show variables like 'character%'
查看mysql字符集
2.打开mysql配置文件my.cnf
vi /etc/my.cnf
3.我的mysql5.6没有[client]这个字段,是我加上去的
然后,在[client]字段下添加:
default-character-set = utf8
character-server-set = utf8
collation-server = utf8_general_ci(这个不设置也可以)
5.重启mysql服务
systemctl restart mysqld.service
Centos6设置utf8编码:
1.与centos7的my.cnf设置相比,centos6中不能有:
collation-character = utf8_general_ci
否则mysql无法启动。
2.Centos 6中mysql的重启命令如下:
service mysqld.service restart