MySQL Workbench 「Error Code: 1175」が発生した場合の対処法

MySQL Workbench 「Error Code: 1175」が発生した場合の対処法

MySQL Workbench使用時に「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」が発生する場合の対処法を記述してます。

環境

  • OS ubuntu21.10
  • MySQL Ver 8.0.27-0ubuntu0.21.10.1 for Linux on x86_64 ((Ubuntu))
  • MySQL Workbench 8.0.27

エラー全文

「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.	0.000 sec

原因

Workbenchにある制約の問題

対処法

一時的に解除であれば、以下を実行します。

SET SQL_SAFE_UPDATES = 0;

終われば、元に戻します。

SET SQL_SAFE_UPDATES = 1;

恒久的に設定したい場合は、Workbenchの、Edit > Preferencesより

SQL Editorにある「Safe Update」のチェックを外して、DBサーバーと再接続またはWorkbenchを再起動します。