When you delete a row of data from a MySQL database, the following error occurs: ERROR1175 (HY000): Youareusingsafeupdatemodeandyoutriedtou.
When You operate the MySQL database and delete a row of data in the table, the following ERROR occurs: ERROR 1175 (HY000): you are using safe update mode and You tried to u.
MySQL ERROR: ERROR 1175: You are using safe update mode solution
[Date:] Source: Linux community Author: mofansheng [Font:]
When you operate the MySQL database and delete a row of data in the table, the following ERROR occurs: ERROR 1175 (HY000 ): you are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
Error message: the secure update mode is being used. The where condition of the key column is not used in the table to update the table;
The reason is: mysql has a variable named SQL _SAFE_UPDATES. To ensure the security of the database update operation, the default value is 1, so the update fails.
Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
Mysql> select * from test;
+ ---- + -------- +
| Id | name |
+ ---- + -------- +
| 1 | anglea |
| 2 | baby |
| 3 | jerry |
| 4 | tom |
| 5 | yong |
+ ---- + -------- +
Mysql> delete from test where name = 'yong ';
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
View settings:
1
2
3
4
5
6
Mysql> show variables like 'SQL _ safe % ';
+ ------------------ + ------- +
| Variable_name | Value |
+ ------------------ + ------- +
| SQL _safe_updates | ON |
+ ------------------ + ------- +
The following describes the values of SQL _SAFE_UPDATES when the variables are 0 and 1:
SQL _SAFE_UPDATES has two values: 0 and 1, or ON and OFF;
SQL _SAFE_UPDATES = 1. ON, the update and delete operation statements without the where and limit conditions cannot be executed, even the update and delete operations with the where and limit conditions but without the key column cannot be executed.
SQL _SAFE_UPDATES = 0. When OFF, the update and delete operations will be executed smoothly. Obviously, the default value of this variable is 1.
Therefore, when a 1175 error occurs, you can set the SQL _SAFE_UPDATES value to 0 OFF before performing the update;
You can run either of the following two commands;
Mysql> set SQL _safe_updates = 0;
Mysql> set SQL _safe_updates = off;
1
2
3
4
5
6
7
8
9
Mysql> show variables like 'SQL _ safe % ';
+ ------------------ + ------- +
| Variable_name | Value |
+ ------------------ + ------- +
| SQL _safe_updates | OFF |
+ ------------------ + ------- +
Mysql> delete from test where name = 'yong ';
Query OK, 1 row affected (0.00 sec)
The change only takes effect currently. log out of mysql and resume to the default value after logon.
This article permanently updates the link address: