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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_43054397/article/details/91843134

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

 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

    show variables like '%safe_update%';
    

    发现safe_update模式是开启的

  • 关闭模式

    SET SQL_SAFE_UPDATES = 0;
    


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

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

    SET SQL_SAFE_UPDATES = 1;
    

猜你喜欢

转载自blog.csdn.net/weixin_43054397/article/details/91843134
今日推荐