使用 MySQL Workbench 5.2 在表上执行更新命令时出错(错误代码:1175)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14231278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:07:39  来源:igfitidea点击:

Error (Error Code: 1175) during executing update command on table using MySQL Workbench 5.2

mysqlsql-updatemysql-workbencherror-code

提问by Ripon Al Wasim

I'm using MySQL Server5.5 in which MySQL Workbench 5.2 CE is included. I'm using MySQL Workbench 5.2 . I have a table named userin DB. I executed the following command on SQL Editor at MySQL Workbench:

我正在使用 MySQL Server5.5,其中包含 MySQL Workbench 5.2 CE。我正在使用 MySQL Workbench 5.2 。我在数据库中有一个名为user的表。我在 MySQL Workbench 的 SQL Editor 上执行了以下命令:

UPDATE user SET email = '[email protected]' WHERE email='[email protected]';

But unfortunately I got the following error:

但不幸的是我收到以下错误:

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 -> Query Editor and reconnect.

What's the wrong? Help is highly appreciated.

怎么了?非常感谢帮助。

回答by John Woo

Every time you encountered that kind of error when trying to update rows in mysql, It's because you tried to update a table without a WHERE that uses a KEYcolumn.

每次尝试更新 mysql 中的行时遇到这种错误,这是因为您尝试更新没有使用KEY列的 WHERE 的表。

You can fix it using,

你可以使用修复它,

SET SQL_SAFE_UPDATES=0;
UPDATE user SET email = '[email protected]' WHERE email='[email protected]';

or in the WorkBench

或在工作台

  • Edit -> Preferences -> SQL Queries
  • Uncheck Forbid UPDATE and DELETE statements without a WHERE clause (safe updates)
  • Query --> Reconnect to Server
  • 编辑 -> 首选项 -> SQL 查询
  • 取消选中没有 WHERE 子句的 Forbid UPDATE 和 DELETE 语句(安全更新)
  • 查询 --> 重新连接到服务器

enter image description here

enter image description here

回答by Cristian

It is more correct to deactivate and reactivate

停用和重新激活更正确

SET SQL_SAFE_UPDATES=0; --disable
UPDATE user SET email = '[email protected]' WHERE email='[email protected]';
SET SQL_SAFE_UPDATES=1; --enable