Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 755
Ripon Al Wasim Avatar asked Jan 09 '13 08:01

Ripon Al Wasim


People also ask

How do I disable safe mode in MySQL Workbench Mac?

You also can disable safe mode in MySQL Workbench, go to Edit -> Preferences -> SQL Editor, and uncheck "Safe Updates" check box.


2 Answers

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

like image 92
John Woo Avatar answered Oct 19 '22 03:10

John Woo


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
like image 33
Cristian Avatar answered Oct 19 '22 03:10

Cristian