MySQL sql_safe_updates 安全更新模式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013332981/article/details/82012406
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.
简单翻译一下:
你正在使用 安全更新模式(safe upate mode)并且你在尝试 update 一个表时 没有用带有键的列 作为where条件,在首选项中切换选项。

这个错是我在生产环境执行一个更新sql时候遇到的。

像这种:

update students set name='drake' where name='chuan';

这是因为没有限定条件,会将表中所有的记录都修改一遍,开启了安全更新模式(safe update mode)。即:

set [global] SQL_SAFE_UPDATES = 1;

 可以查看下目前处于什么模式;如果打开了可以关闭

我本地环境

生产环境:

可以关闭此模式
set  SQL_SAFE_UPDATES = 0;即可执行成功

可以参考文章:safe update mode 

猜你喜欢

转载自blog.csdn.net/u013332981/article/details/82012406