1、进入mysql,查看默认字符集;
mysql>show variables like 'char%';
2、退出mysql;
3、输入命令:sudo gedit /etc/mysql/conf.d/mysql.cnf
4、在[mysql]下面添加:
no-auto-rehash
default-character-set=utf8
5、再输入指令:sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
6、在[mysqld]下面添加:
socket = /var/run/mysqld/mysqld.sock
port = 3306
character-set-server=utf8
7、重启mysql:sudo /etc/init.d/mysql restart
8、再查看字符集:
mysql>show variables like 'char%';