18

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 user in DB. I executed the following command on SQL Editor at MySQL Workbench:

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.

3
  • possible duplicate of MySQL error code: 1175 when updating Commented Jan 9, 2013 at 8:47
  • 1
    user is a reserved word, you probably also need to enclose it with backticks. Commented Jan 9, 2013 at 8:49
  • @a_horse_with_no_name: good suggestion though I did not face any problem in my case Commented Jan 9, 2013 at 9:06

2 Answers 2

36

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 KEY column.

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

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

@a_horse_with_no_name but email column has no key defined.
SQL_SAFE_UPDATES is a system variable, right? How can I get the list of system variable in MySQL Workbench?
in workbench 6.2 I didn't find "SQL Queries" instead found "SQL Editor"
3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.