mysql 安全模式

今天,执行一条delete语句的时候报错如下:
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.

大意是:数据库运行在safe update 模式,修改表结构的where必须带主键。即非主键条件下无法执行update、delete。

解决方法:
方法一:
临时修改安全模式:SET SQL_SAFE_UPDATES = 0;
再执行update/delete。
恢复安全模式:SET SQL_SAFE_UPDATES = 1;

方法二:
博主使用的是MySQL Workbench,也可以根据提示直接修改默认设置:Preferences -> SQL Editor and reconnect

posted @ 2018-03-30 00:13  AmyZYX  阅读(2754)  评论(0编辑  收藏  举报