更改mysql数据库编码为GBK
刚刚安装完mysql后
从cmd中进入mysql数据库
命令行中输入:
mysql -uroot -p123
进入mysql数据库中
命令行中输入:
status;
查看当前数据库中的编码
如下:
--------------
mysql Ver 14.12 Distrib 5.1.7-beta, for Win32 (ia32)
Connection id: 5
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.1.12-beta-community-nt
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 1 hour 7 min 10 sec
Threads: 1 Questions: 26 Slow queries: 0 Opens: 13 Flush tables: 1 Open tables: 0 Queries per second avg: 0.006
--------------
latin1为mysql默认编码
进入mysql的安装目录
用记事本打开 my.ini
CTRL+F 查找latin1
将lation1改为GBK
一共改两个
替换完成
我们进入cmd中
重新启动mysql的服务
net stop mysql;
net start mysql;
重启过后
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
将改为
Server characterset: gbk
Db characterset: gbk
Client characterset: gbk
Conn. characterset: gbk
——————————————————————————
补充:
如果出现
Server characterset: gbk
Db characterset: gbk
Client characterset: latin1
Conn. characterset: latin1
则只能用下面方法
set names gbk;