DB

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.

오은이 2024. 11. 26. 21:57

 

 

 

아래와 같이 사용자 이름 컬럼인 usernm으로 delete 쿼리를 사용했더니

delete from user where usernm = 'test' ;

 

 

 

 

이런 에러가 발생

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 Update Mode"**로 인해 발생한 것. Safe Update Mode는 사용자가 UPDATE 또는 DELETE 쿼리를 실행할 때, 안전성을 높이기 위해 WHERE 절에 키 컬럼(primary key, unique key 등)을 사용하도록 강제하는 기능이다. 이는 실수로 전체 데이터를 삭제하거나 업데이트하는 것을 방지하기 위한 안전장치와 같은 것이다.

 

 

 

 

 

 

 

해결방법 1.


WHERE 절에 키 컬럼 사용

usernm 대신 primary Key 컬럼인 userid를 사용하면 delete 가능

delete from user where userid = 'test1111';

 

 

 

 

 

 

해결방법 2.

 

MySQL Workbench에서 Safe Update Mode를 비활성화하는 방법:

  • MySQL Workbench에서 Edit > Preferences > SQL Editor로 이동
  • Safe Updates 옵션을 찾아 체크박스 해제

 

 

이후 MySQL Workbench 재부팅하면 해결