MySQL Error Code: 1175. You are using safe update 错误原因及解决方案

桃扇骨 2022-01-15 15:29 503阅读 0赞

当我使用MySQL 执行更新或删除操作时,mysql 报了这样一个错误:

  1. 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.

原因: MySql运行在safe-updates模式下,该模式会导致非主键条件下无法执行update或者delete命令

  • 查看一下safe_updates

    1. show variables like '%safe_update%';

    20190613131356727.png

    发现safe_update模式是开启的

  • 关闭模式

    1. SET SQL_SAFE_UPDATES = 0;

    20190613131546736.png
    现在再进行update ,delete 操作就不会报错了

  • 但是如果有些情况下为了安全起见,也可以设置开启safe_updates 模式:

    1. SET SQL_SAFE_UPDATES = 1;

发表评论

表情:
评论列表 (有 0 条评论,503人围观)

还没有评论,来说两句吧...

相关阅读