一、經過 show variables like '%char%';查看MySQL字符集狀況mysql
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/share/mysql/charsets/ |
+--------------------------+----------------------------+sql
二、修改mysql配置文件vim
#備份配置文件
sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf_2
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 修改處1:添加如下2行
[client]
default-character-set=utf8
[mysqld]
# 修改處2:添加如下3行
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci.net
三、重啓mysql
service mysql restartrest
四、查看字符集
mysql -uroot -p
mysql> show variables like "%char%";
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+server
---------------------
做者:zheng_lan_fang
來源:CSDN
原文:https://blog.csdn.net/zheng_lan_fang/article/details/77941232
版權聲明:本文爲博主原創文章,轉載請附上博文連接!blog