当前位置: > 其它学习 > 日常运维 >

Ubuntu16.04中修改MySQL的character_set_database和character_set_server 的方法

时间:2019-03-20 01:21来源:linux.it.net.cn 作者:IT
修改前执行如下命令
mysql> show variables like "%char%";

结果是这样子的
+--------------------------+---------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/Cellar/mysql/5.7.21/share/mysql/charsets/ |
+--------------------------+---------------------------------------------------------------+
8 rows in set

$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

在 [mysqld] 域下加上:
character-set-server=utf8

再重新启动 MySQL 服务即可:
$ sudo systemctl restart mysql

这样就解决问题了。

(责任编辑:IT)
------分隔线----------------------------