Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL error code: 1175 during UPDATE in MySQL Workbench

I'm trying to update the column visited to give it the value 1. I use MySQL workbench, and I'm writing the statement in the SQL editor from inside the workbench. I'm writing the following command:

UPDATE tablename SET columnname=1; 

It gives me the following error:

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

I followed the instructions, and I unchecked the safe update option from the Edit menu then Preferences then SQL Editor. The same error still appear & I'm not able to update this value. Please, tell me what is wrong?

like image 253
Jury A Avatar asked Jul 12 '12 08:07

Jury A


People also ask

How do I change the safe update mode in MySQL Workbench?

SET SQL_SAFE_UPDATES=0; You also can disable safe mode in MySQL Workbench, go to Edit -> Preferences -> SQL Editor, and uncheck "Safe Updates" check box. Then reconnect to MySQL server by going to Query -> Reconnect to Server. To turn safe mode back on, use the following code.

What is MySQL safe update mode?

If the safe UPDATE mode is enabled, MySQL does not run the UPDATE or DELETE if you try to execute them without a WHERE and LIMIT statement also if there is no condition with the key column.

What is error code 1054 in MySQL?

The ERROR 1054 in MySQL occurs because MySQL can't find the column or field you specified in your statement. This error can happen when you execute any valid MySQL statements like a SELECT , INSERT , UPDATE , or ALTER TABLE statement. This tutorial will help you fix the error by adjusting your SQL statements.


1 Answers

It looks like your MySql session has the safe-updates option set. This means that you can't update or delete records without specifying a key (ex. primary key) in the where clause.

Try:

SET SQL_SAFE_UPDATES = 0; 

Or you can modify your query to follow the rule (use primary key in where clause).

like image 74
Habibillah Avatar answered Sep 18 '22 14:09

Habibillah