对 mysql Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,I的解决
2013-07-09 10:06
543 查看
对于常见的乱码问题,有的在数据库本身已经为gbk或gb2312时候,但是查询出来却是乱码,这是因为mysql在连接的过程中还有道编码,因此将连接的编码设为gb2312或utf-8
即可,如:
jdbc:mysql://localhost:3306/ipanel?useUnicode=true&characterEncoding=UTF-8
hibernate和jdbc的参数设置是不一样,但大体相同,网上类似的资料很多。
最重要的是这个问题:
Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,IMPLICIT) for operation '='
相信有很多人碰到,意思是说字符编码不一样,不能进行比较,也就是说数据库内部的编码都不一样,有的数据是
gbk_chinese_ci,有的数据是gb2312_chinese_ci,因此解决此问题的核心就是将数据库所有的编码进行统一。
进入命令行模式,
如果MySQL数据库已经安装好,可以使用下列SQL命令查看MySQL当前的字符集设置:
mysql> SHOW VARIABLES LIKE 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
7 rows in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'collation_%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)
依次执行:
set character_set_client =gb2312;
set character_set_connection =gb2312;
set character_set_database =gb2312;
set character_set_results =gb2312;
set character_set_server =gb2312;
set character_set_system =gb2312; --此处utf-8也可以
然后执行:
SET collation_server = gb2312_chinese_ci
SET collation_database = gb2312_chinese_ci
SET collation_connection =gb2312_chinese_ci
执行完之后,请检查mysql下每个数据库,表,字段是否都是gb2312,不是则改过来,这样子就不会出现
Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,IMPLICIT) for operation '='这个错误了,网上有资料说要重装,其实根本就不必,改动其编码即可
相关文章推荐
- 对 mysql Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,I的解决
- MySql Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,IMPLICIT) for operation '=' 错误解决方法
- 对 mysql Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,I的解决
- 解决Mysql:Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
- mysql错误提示Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)的一个解决办法
- C# mysql 做成安装文件之后出现 Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (gb2312_chinese_ci,IMPLICIT) 错误
- mysql错误提示Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)的一个解决办法
- 如何解决Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,IMPLICIT)的问题
- 解决Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,IMPLICIT) for operation
- MYSQL错误:Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
- MSQL Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,SYSCONST) for operation 'UNION' 错误解决办法
- 解决Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operatio
- 解决Illegal mix of collations (gb2312_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operati
- Illegal mix of collations (gb2312_chinese_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation
- Illegal mix of collations (latin5_turkish_ci,IMPLICIT) and (gb2312_chinese_ci,COERCIBLE) for operati
- Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation '='
- Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gbk_chinese_ci,COERCIBLE) for operation '=' 一个解决办法(转载)
- Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gbk_chinese_ci,COERCIBLE) for operation '=' 一个解决办法(转载)
- Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
- Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='