登录mysql:
mysql -u用户名 -p密码
show variables like 'character%';
显示如下:
-
mysql> show variables like 'character%';
-
+--------------------------+----------------------------+
-
| 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/share/mysql/charsets/ |
-
+--------------------------+----------------------------+
打开配置文件:
/etc/mysql/mysql.conf.d/mysqld.cnf
操作如下:
vim mysqld.cnf
找到:[mysqld]行,添加: character_set_server = utf8 即可
重启mysql: service mysql restart
再次查看:
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
-
mysql> show variables like 'character%';
-
+--------------------------+----------------------------+
-
| Variable_name | Value |
-
+--------------------------+----------------------------+
-
| character_set_client | utf8 |
-
| character_set_connection | utf8 |
-
| character_set_database | utf8 |
-
| character_set_filesystem | binary |
-
| character_set_results | utf8 |
-
| character_set_server | utf8 |
-
| character_set_system | utf8 |
-
| character_sets_dir | /usr/share/mysql/charsets/ |
-
+--------------------------+----------------------------+
阅读(664) | 评论(0) | 转发(0) |