- Linux下MySQL5.6的修改字符集编码为UTF8(解决中文乱码问题)
-
Linux下MySQL5.6的修改字符集编码为UTF8(解决中文乱码问题)
一、登录MySQL查看用show variables like 'character_set_%';
下字符集,显示如下:
123456789101112 +
--------------------------+----------------------------+
| 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/
|+
--------------------------+----------------------------+
12345678910111213141516171819 1、在[client]字段里加入
default
-
character
-
set
=utf8,如下:
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
default
-
character
-
set
=utf8
2、在[mysqld]字段里加入
character
-
set
-server=utf8,如下:
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
character
-
set
-server=utf8
3、在[mysql]字段里加入
default
-
character
-
set
=utf8,如下:
[mysql]
no
-auto-rehash
default
-
character
-
set
=utf8
123456789101112 +
--------------------------+----------------------------+
| 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/
|+
--------------------------+----------------------------+
(本人转载网上文档)