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



#事故現場

mysql執行update操作報錯:

  • sql如下:
update psmp.Users set name='Jack' where name='Lily';
  • 報錯如下:

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

  • 分析

這是因為MySql運行在safe-updates模式下,該模式會導致非主鍵條件下無法執行update或者delete命令。
可以通過以下SQL進行狀態查詢:

show variables like 'SQL_SAFE_UPDATES';

在這里插入圖片描述

#解決方法

  • 執行下面的sql,關閉safe-updates模式:
SET SQL_SAFE_UPDATES = 0;

SET SQL_SAFE_UPDATES = false;
  • 執行下面的sql,打開safe-updates模式:
SET SQL_SAFE_UPDATES = 1;

SET SQL_SAFE_UPDATES = true;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM