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 = 'abc@yahoo.com' WHERE email='ripon.wasim@yahoo.com';

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.

AndroidLearner
  • 4,500
  • 4
  • 31
  • 62
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
  • possible duplicate of [MySQL error code: 1175 when updating](http://stackoverflow.com/questions/11448068/mysql-error-code-1175-when-updating) – fthiella Jan 09 '13 at 08:47
  • 1
    `user` is a reserved word, you probably also need to enclose it with backticks. –  Jan 09 '13 at 08:49
  • @a_horse_with_no_name: good suggestion though I did not face any problem in my case – Ripon Al Wasim Jan 09 '13 at 09:06

2 Answers2

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 = 'abc@yahoo.com' WHERE email='ripon.wasim@yahoo.com';

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

Vishrant
  • 15,456
  • 11
  • 71
  • 120
John Woo
  • 258,903
  • 69
  • 498
  • 492
3

It is more correct to deactivate and reactivate

SET SQL_SAFE_UPDATES=0; --disable
UPDATE user SET email = 'abc@yahoo.com' WHERE email='ripon.wasim@yahoo.com';
SET SQL_SAFE_UPDATES=1; --enable
Cristian
  • 43
  • 8