发布于 4年前

MySQL Workbench执行删除报错:Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

在MySQL workbench执行删除语句:

delete from mytable where name != '' && name is not null;

执行后,workbench提示:

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 Editor and reconnect. 0.000 sec

原因是MySQL是在安全更新(safe-updates)模式下,该模式会导致非主键条件下无法执行update或者delete命令。

解决方法:把变量SQL_SAFE_UPDATES设置为0

执行命令如下:

SET SQL_SAFE_UPDATES = 0;

切换为安全更新模式,执行命令:

SET SQL_SAFE_UPDATES = 1;
©2020 edoou.com   京ICP备16001874号-3