mysql 存储失败_为什么MYSQL的储存语句出现这样的错误

展开全部

基本判定为字符集的问题

通过32313133353236313431303231363533e58685e5aeb931333431353362以下代码可以复现:drop  procedure if exists delete_employees ;

delimiter $$

-- by sleest, 2019/05/23 此处为复现问题, 特意指定入参字符集为mysql默认字符集latin1

create procedure delete_employees(in xm char(6) CHARSET latin1 COLLATE latin1_bin)

begin

-- begin 测试用

drop temporary table if exists employees ;

create temporary table employees(`姓名` char(6));

-- end 测试用

delete from employees where 姓名=xm;

end $$

call delete_employees('李丽');

在终端或者连接工具中执行会得到一致的错误call delete_employees('李丽');Error Code: 1366. Incorrect string value: '\xE6\x9D\x8E\xE4\xB8\xBD' for column 'xm' at row 1

这里建议在建立完存储过程后, 查下存储过程的字符集:show create procedure delete_employees;

主要看结果中的这三列# character_set_client, collation_connection, Database Collation

'utf8',               'utf8_general_ci',    'utf8mb4_general_ci'

本人使用的环境是utf8mb4字符集, 你看看你的会不会是latin1, 如果是的话两种方案改数据库字符集, 通用些utf8或者支持emjio的utf8mb4, 重启mysql服务再重连试验

建立的每个存储过程手动指定字符集

如:create procedure delete_employees(in xm char(6) CHARSET utf8 COLLATE utf8_bin) ...

这样再试试

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值