打开终端
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
在文件的
[mysqld]
#
# * Basic Settings
#
user = MySQL
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
character-set-server=utf8 #增加这个设置
skip-external-locking
然后打开文件
sudo vi /etc/mysql/conf.d/mysql.cnf
[mysql]
default-character-set=utf8 #增加这个设置
/etc/init.d/mysql restart
最后重启服务就好了。