【ubuntu】mysql默认的配置文件路径
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
修改配置文件, [mysqld] 和 [client] 配置项增加内容
# mysqld [mysqld] character-set-server=utf8 collation-server=utf8_general_ci init_connect='SET NAMES utf8' # client [client] default-character-set=utf8
重启服务
sudo /etc/init.d/mysql restart
验证结果
mysql> show variables like 'character_set_%'; mysql> show variables like 'collation_%';
修改之前:
修改之后: