日期:2014-05-16  浏览次数:20766 次

为什么在mysql上面查出来的汉字都是乱码?
我再Navicat 插入数据(包括汉字) 查询显示都是正常.
在服务器上查询的时候 汉字都显示为乱码 
如下: 
mysql> SELECT * FROM emp;
+-------+--------+-----------+------------+---------+
| empno | ename | job | hiredate | sal |
+-------+--------+-----------+------------+---------+
| 7369 | dong | xiaos | 2003-10-09 | 1500.90 |
| 7698 | 张� | 销售 | 2005-03-12 | 800.00 |
| 7762 | å??æ?? | 销售 | 2005-03-09 | 1000.00 |
| 7782 | æ
  | 7839 | ç??æ?? | ç»ç? | 2006-09-01 | 2500.00 |
| 8694 | æ祺 | å??æ?å‘? | 2003-10-01 | 3000.00 |
+-------+--------+-----------+------------+---------+
7 rows in set (0.00 sec)
字符集设置如下:
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/local/mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+
8 rows in set (0.00 sec)
请高手指点 怎么回事

------解决方案--------------------
set names gbk;
------解决方案--------------------
set names 'gbk';
然后再试。

http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
MySQL 中文显示乱码
------解决方案--------------------
set names 'gbk';