Recently I was performing one very simple MySQL query. But I am not getting success for that query. So after few mins of research I am found the solution for that.
Actually my query was just like below:
Isn’t it so simple? yes it is. But it was not working. Once I have started to debug the process I found that MySQL is throwing the below error:
“You are using safe update mode and you tried to update a table without a WHERE clause that uses a KEY column.”
What is MySQL Safe Mode?
MySQL will refuse to run the UPDATE or DELETE query if executed without the WHERE clause or LIMIT clause. MySQL will also refuse the query which have WHERE clause but there is no condition with the KEY column.
So below query will also be refused if safe mode is enabled:
How to disable MySQL Safe Mode?
There is a simple way to disable the MySQL Safe Mode. We can disable it with simple query.
Have a look at below query:
UPDATE table_name SET bDeleted=0 WHERE name='xyz';
Note: MySQL will also refuse the query which have WHERE clause but there is no condition with the KEY column.