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 workben
On WorkBench I resolved it By deactivating the safe update mode:
-Edit -> Preferences -> Sql Editor then uncheck Safe update.
All that's needed is: Start a new query and run:
SET SQL_SAFE_UPDATES = 0;
Then: Run the query that you were trying to run that wasn't previously working.
Follow the following steps before executing the UPDATE command: In MySQL Workbench
Edit
--> Preferences
"SQL Editor"
tab and uncheck
"Safe Updates" check box
Query
--> Reconnect to Server
// logout and then loginp.s., No need to restart the MySQL daemon!
The simplest solution is to define the row limit and execute. This is done for safety purposes.
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
operation
On 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
Option
For beginners, a useful startup option is
--safe-updates
(or--i-am-a-dummy
, which has the same effect). It is helpful for cases when you might have issued aDELETE FROM tbl_name
statement but forgotten theWHERE
clause. Normally, such a statement deletes all rows from the table. With--safe-updates
, you can delete rows only by specifying the key values that identify them. This helps prevent accidents.When you use the
--safe-updates
option, mysql issues the following statement when it connects to the MySQL server:
SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;
It is safe to turn on this option while you deal with production database. Otherwise, you must be very careful not accidentally deleting important data.