一,右键数据库链接,点击链接属性如图:
二,修改以下信息,如图:
选择高级选项页签==》去掉使用MySQL字符集复选框==》选择GB2312字符编码==》点击确定
三,进入navicat的控制台后,show variables like 'char%';命令后如下:
+--------------------------+---------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | D:/mysql-5.1.32-win32/share/charsets/ |
此时我们需要在控制台运行 set names 'gbk'命令,运行后再次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 |
| character_sets_dir | D:/mysql-5.1.32-win32/share/charsets/ |
客户端连接环境设置算是完成了。接着中文数据该怎么插还是怎么插,不会再有乱码出现。
至于从.sql.txt等文本批量导入数据,则需要将相应的文件转化为gbk格式保存再导入,否则导入后会乱码
如果输出的编码格式不是以上格式,也可以通过下面的SQL语句来对其进行修改,MYSQL命令设置编码格式: set character_set_server = 'utf8';