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?
This is for Mac, but must be same for other OS except the location of the preferences.
The error we get when we try an unsafe
DELETE
operationOn the new window, uncheck the option
Safe updates
Then close and reopen the connection. No need to restart the service.
Now we are going to try the
DELETE
again with successful results.So what is all about this safe updates? It is not an evil thing. This is what MySql says about it.
Using the
--safe-updates
OptionIt is safe to turn on this option while you deal with production database. Otherwise, you must be very careful not accidentally deleting important data.
No need to set SQL_SAFE_UPDATES to 0, I would really discourage it to do it that way. Just add in the WHERE clause a KEY-value that matches everything like a primary-key comparing to 0, so instead of writing:
Now you can be assured every record is updated like you expect.
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 and reconnect.
Turn OFF "Safe Update Mode" temporary
Turn OFF "Safe Update Mode" forever
Mysql workbench 8.0:
Old version can:
In the MySQL Workbech version 6.2 don't exits the Preference
In this case it's possible use:SQLQueries
options.SET SQL_SAFE_UPDATES=0;
True, this is pointless for the most examples. But finally, I came to the following statement and it works fine: