今天运行mysql拼接符concat报错Illegal mix of collations (gbk_chinese_ci,IMPLICIT)and(utf8_general_ci,COERCIBLE)
很明显是字符符GBK和utf8的问题
利用mysql的字符串转换函数CONVERT将参数格式化为char类型就可以了论文网。举例: concat('数量:',CONVERT(int1,char),CONVERT(int2,char),'金额:',CONVERT(double1,char),CONVERT(double2,char))
第一步:查看mysql根目录的my.ini是否修改成功
将default-character-set=latin1 修改成 default-character-set=utf8
character-set-server=utf8 修改成 character-set-server=utf8
(修改保存后,需要重启mysql)
字符不同的话,需要修改成相同字符
set collation_connection = utf8_general_ci(或utf8_unicode_ci)
第二步:输入sql命令,查看mysql字符集设置
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 | C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------+
如果不是utf8格式,则需要修改成utf8。
sql命令:set character_set_client = utf8;
再查看具体字符,输入sql命令:show variables like "%coll%";
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+ Mysql错误提示Illegal mix of collations (gbk_chinese_ci,IMPLICIT)and(utf8_general_ci,COERCIBLE):http://www.751com.cn/fanwen/lunwen_44162.html