mysql如何关闭safe update mode

文章描述了一条SQL更新语句在执行时遇到的1175错误,该错误是因为在安全更新模式下尝试更新表而没有使用键列。解决方案是关闭全局变量sql_safe_updates,将其设置为0,以允许不基于键的更新操作。在MySQL8.0中,此变量默认为关闭状态。

update sales set city = '上海'where city = 'shanghai'; 这条语句报出 如下错误

update sales set city = '上海'where city = 'shanghai'    Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. 

解决方案直接如下图

 update sales set city = '上海'where city = 'shanghai';
show global variables like '%sql_safe_updates';
set global sql_safe_updates = 0;

将global 的变量sql_safe_updates = 0即可,mysql8.0默认是off状态

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值