进入数据库先查看编码格式:
show variables like "%char%";
+--------------------------+---------------+
| Variable_name | Value |
+--------------------------+---------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | utf8 |
| character_set_system | utf8 |
+--------------------------+-------------+
要确保编码是这种格式,其中:
编码需要是gbk,而不能是utf8;character_set_client
character_set_connection
character_set_results
修改mysql的配置文件my.ini(路径:一般位于安装路径根目录,或者安装路径根目录的bin下,或者Linux下/etc/my.cnf。)
在my.ini中:
搜索到[mysqld],修改或添加character-set-server=utf8;
//以下2个可以不修改,一般默认就是gbk
搜索到[client],修改或添加default-character-set=gbk;
搜到到[mysql],修改或添加default-character-set=gbk;
完成