Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci
程序员文章站
2022-07-11 07:50:29
...
事情是这样晒的,有两个独立部署的web服务器环境A和B,A的数据库和B的数据库几乎是一样的(库、表、字段、数据),也有可能没发现不一样的地方。A正常,B请求异常,如下所示:
### Error querying database. Cause: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=' ### The error may exist in URL [jar:file:/data/yangtun_show/6_cgp/scp-cgp.jar!/BOOT-INF/classes!/mapper/CaseRegistrationMapper.xml] ### The error may involve com.bjzhianjia.scp.cgp.mapper.CaseRegistrationMapper.getStatisByDept-Inline ### The error occurred while setting parameters ###
SQL: xxxxxxx and ?<=crt_time and crt_time <= ? and yyyyyyyyyyy### Cause: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=' ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1267]; Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<='; nested exception is java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=
这样的问题出现了,好像没见过(不要慌,拿起想起拍个照,然后发个朋友圈)。定位问题需要从头开始,哪个个web接口发起的请求,后台做了什么处理,数据库执行的时候SQL现场是什么样子的。
思路有了,开始在B中还原现场。从web发起请求的接口是http://i.love.you:forever/queryPath?startTime=2020-04-00+00:17:16&endTime=2020-07-22+00:17:16,复盘成功。发现了奇怪的地方,请求参数中startTime=2020-04-00+00:17:1有00,换成01试试http://i.love.you:forever/queryPath?startTime=2020-04-01+00:17:16&endTime=2020-07-22+00:17:16,成功了。 问题解决了!
Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<='; 看来并不可怕,但是。。。。。。
why?A行,B不行原因是什么呢?
应该有两种可能性:第一是web程序对日期解析支持不同,可能受操作系统影响;第二是数据库本身支持对异常日期的解析。
继续探索。。。
### Error querying database. Cause: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=' ### The error may exist in URL [jar:file:/data/yangtun_show/6_cgp/scp-cgp.jar!/BOOT-INF/classes!/mapper/CaseRegistrationMapper.xml] ### The error may involve com.bjzhianjia.scp.cgp.mapper.CaseRegistrationMapper.getStatisByDept-Inline ### The error occurred while setting parameters ###
SQL: xxxxxxx and ?<=crt_time and crt_time <= ? and yyyyyyyyyyy### Cause: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=' ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1267]; Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<='; nested exception is java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=
这样的问题出现了,好像没见过(不要慌,拿起想起拍个照,然后发个朋友圈)。定位问题需要从头开始,哪个个web接口发起的请求,后台做了什么处理,数据库执行的时候SQL现场是什么样子的。
思路有了,开始在B中还原现场。从web发起请求的接口是http://i.love.you:forever/queryPath?startTime=2020-04-00+00:17:16&endTime=2020-07-22+00:17:16,复盘成功。发现了奇怪的地方,请求参数中startTime=2020-04-00+00:17:1有00,换成01试试http://i.love.you:forever/queryPath?startTime=2020-04-01+00:17:16&endTime=2020-07-22+00:17:16,成功了。 问题解决了!
Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<='; 看来并不可怕,但是。。。。。。
why?A行,B不行原因是什么呢?
应该有两种可能性:第一是web程序对日期解析支持不同,可能受操作系统影响;第二是数据库本身支持对异常日期的解析。
继续探索。。。
推荐阅读
-
解决 Mysql Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)
-
Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci
-
对mysql Illegal mix of collations(gbk_chinese_ci,IMPLICIT) a_MySQL
-
MySQL查询:Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) fo
-
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (_MySQL
-
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (_MySQL
-
MySQL Illegal mix of collations for operation 'like' 解决方案
-
Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (gbk_chinese_ci,COERCIB解决思路
-
Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (gbk_chinese_ci,COERCIB解决思路
-
mysql 保存数据出现 Illegal mix of collations (gbk_chinese_ci