mysql5.6修改字符编码,ERR:Illegal mix of collations for operation 'concat'
mysql5.6修改字符编码,ERR:Illegal mix of collations for operation 'concat'
1.问题起因:搭建环境初始化mysql的时候看到mysql配置文件[cloent]下有设置编码为default-character-set = utf8,大意误以为是全局配置了,其实还需要在[mysqld]下添加character_set_server = utf8参数的
2.尝试在线处理:
mysql> show variables like 'collation_%';
mysql> show variables like 'character_set_%';
看到编码为:latin1
便尝试使用set命令修改:set GLOBAL Variable_name=utf8_general_ci; set GLOBAL Variable_name=utf8;
结果在执行存储过程中:call xx_ya_stats_xx_daily(2018-05-18,3); 仍然报错:Illegal mix of collations for operation 'concat'
最后再查看数据库的编码,自动恢复为latin1
3.个人结论:mysql在初始化时使用latin1字符编码,导致了里面的库表数据都是latin1字符编码,虽然改了全局的编码,但库表数据编码还是没有改到,导致失败。
4.最终解决办法:把数据库备份导出,重新初始化mysql实例,再导入数据,恢复正常。
5.步骤:
导出:mysqldump -uroot -h'127.0.0.1' -P3306 -pxxx-E -R db_name > db_name.sql
修改sql:cat db_name.sql | grep -v "ALTER DATABASE \`db_name\` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;" > db_name_new.sql
初始化同样的新实例:mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=xxxxx
设置密码:mysql> grant all privileges on *.* to 'root'@'%' IDENTIFIED BY 'xxxx';
mysql> flush privileges;
修改密码:mysqladmin -h127.0.0.1 -uroot -p --port=3336 password "new_passwd"
开启事件:SET GLOBAL event_scheduler = ON;
查看事件是否开启:mysql> show variables like 'event_scheduler';
创建数据库并指定字符编码:mysql> CREATE database db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
导入数据库:mysql -uroot -h'127.0.0.1' -P3306 -pxxxx db_name < db_name_new.sql
测试:call xx_ya_stats_xxxx_daily(2018-05-18,3);
查看编码:
mysql> show variables like 'collation_%';
mysql> show variables like 'character_set_%';
mysql5.6修改字符编码,ERR:Illegal mix of collations for operation 'concat'的更多相关文章
- Illegal mix of collations for operation 'concat'
在t_employee表中,练习使用concat函数连接字符串时, mysql> select concat('工号为:',fnumber,'的员工的幸福指数:',fsalary/(fage-2 ...
- MySQL Error: Illegal mix of collations for operation 'concat'
在使用concat连接字符串时出现错误:MySQL Error: Illegal mix of collations for operation 'concat' 原因:字段操作默认为UTF8的编码, ...
- Illegal mix of collations for operation 'like' while searching with Ignited-Datatables
Stack Overflow Questions Developer Jobs Tags Users Log In Sign Up Join Stack Overflow to learn, sh ...
- myslq数据库用union all查询出现 #1271 - Illegal mix of collations for operation 'UNION'
出现 #1271 - Illegal mix of collations for operation 'UNION' 的原因是两个字符编码不匹配造成的. 我遇到的是 utf8_general_ci ...
- mysql 客户端连接报错Illegal mix of collations for operation
服务端用的是utf-8,客户端工具打开表和视图是会报Illegal mix of collations for operation错误,经排查,可以采用以下语句解决 SET character_set ...
- 错误之Illegal mix of collations for operation 'like'
内容来自博客:https://www.cnblogs.com/install/p/4417527.html MySQL Illegal mix of collations for operation ...
- mysql5.5修改字符编码
因为mysql版本问题,网上各种修改编码的方法都不行,最后找到下面这条,终于解决! [mysqld]下添加: character-set-server=utf8 collation-server=ut ...
- mysql提示:Illegal mix of collations for operation ‘UNION’
http://www.111cn.net/database/mysql/56096.htm show variables like "%char%"; show variables ...
- 有关mysql的utf8和utf8mb4,以及Illegal mix of collations for operation 'like'
参考以下几个帖子: https://www.cnblogs.com/install/p/4417527.html https://blog.csdn.net/Yetmoon/article/detai ...
随机推荐
- javaScript 之set/get方法的使用
例1:var fe={ name:'leony', $age:null, get age(){ if(this.$age == undefined){ //this.$age == undefined ...
- 【NOI2003】银河英雄传
迭代不一定比递归好 原题: 公元五八○一年,地球居民迁移至金牛座α第二行星,在那里发表银河联邦创立宣言,同年改元为宇宙历元年,并开始向银河系深处拓展. 宇宙历七九九年,银河系的两大军事集团在巴米利恩星 ...
- REST与RPC的简单对比
一.REST:Representational State Transfer,表述性状态转移 REST是一种架构风格,指的是一组架构约束条件和原则.满足这些约束条件和原则的应用程序或设计就是RESTf ...
- 自制数据结构(容器)-java开发用的最多的ArrayList和HashMap
public class MyArrayList<E> { private int capacity = 10; private int size = 0; private E[] val ...
- Where is Silverlight now?
Some time ago, I wrote an article about the comparison between HTML5 and Silverlight. That article w ...
- Tensorflow & Python3 做神经网络(视频教程)
Tensorflow 简介 1.1 科普: 人工神经网络 VS 生物神经网络 1.2 什么是神经网络 (Neural Network) 1.3 神经网络 梯度下降 1.4 科普: 神经网络的黑盒不黑 ...
- 万年历(hao123)代码
网上有很多类似的代码,比如网站:hao123,IP138.日梭万年历网络版 等等,不过日梭万年历相对比较详细,也可以看看另外一篇文章的介绍: 日梭万年历网络版:http://www.cnblogs.c ...
- 【转】每天一个linux命令(16):which命令
原文网址:http://www.cnblogs.com/peida/archive/2012/11/08/2759805.html 我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面 ...
- centos7 lvs keepalived做DNS集群负载
2LVS + keepalived 5 bind dns源站 yum -y install ipvsadm keepalived lvs增加并发 echo "options ip_vs c ...
- 利用springMVC包装类上传多个文件
前端JSP页面代码片段: <!-- springMVC包装类上传文件 --><form name="uploadFiles" id="uploadFil ...