mysql utf8mb4 模糊查询_mysql 处理utf8mb4的问题

jdbc端的characterEncoding=utf8 无法改为utf8mb4

测试:

create table utf8mb4_test (name1 varCHAR(20) CHARACTER SET utf8mb4, name2 varCHAR(20) CHARACTER SET utf8);

通过语句 stmt.execute("set names utf8mb4");

后再执行 stmt.execute("INSERT INTO risk_cds_education_audit_log(os_name,os_company_name)VALUES('1234test','王家园45\uD83D\uDC4C**')");

即可。此种情况,除了将目标表中的字段改为外,无需改动数据库任何地方。

SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';

grant All on poc.* to dbtest@'%' identified by 'Btmysql_1234';

如果mysqld group 设置了character_set_server=utf8mb4,则client端无需做任何改动即可使用。

For Connector/J 5.1.46 and earlier: In order to use the utf8mb4 character set for the connection, the server MUST be configured with character_set_server=utf8mb4; if that is not the case, when UTF-8 is used for characterEncoding in the connection string, it will map to the MySQL character set name utf8, which is an alias for utf8mb3.

For Connector/J 5.1.47 and later: When UTF-8 is used for characterEncoding in the connection string, it maps to the MySQL character set name utf8mb4.

驱动更换为5.1.47即可

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值