Cannot convert string ‘\xE9\x87...‘ from utf8mb4 to binary

版本环境

  • MySQL 8.0.32

问题

使用union连接表后,通过关键字like模糊查询内容时报错。

查看日志show warnnings显示如下:

|level   | code | message                                                    |
|Warning | 1300 | Cannot convert string '\xE9\x87...' from utf8mb4 to binary |

官方解释文档

A condition pushdown into a UNION of queries having LIKE clauses did not preserve the correct character set, leading to an (erroneous) empty result.
We solve this problem in two parts:
By refactoring resolution of LIKE expressions, in which character set determination and propagation were previously performed in two separate blocks of the code that were not always consistent with one another.
By adding, in the internal parse_expression() function, a character set prefix to any literal character string that is cloned.
(Bug #107787, Bug #34359297, Bug #34589153)

Bug #107787 链接

临时解决办法

修改optimizer_switchderived_condition_pushdown值为off

# 设置当前会话
set optimizer_switch='derived_condition_pushdown=off';
# 设置全局值
set global optimizer_switch='derived_condition_pushdown=off';
# 设置全局值,并固化到配置⽂件my.cnf
set persist optimizer_switch='derived_condition_pushdown=off';

重启数据库systemctl restart mysqld,解决~~

原文:https://greatsql.cn/thread-209-1-1.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值