mysql错误:ERROR 1175: You are using safe update mode 解决方法

操作mysql数据库,删除表中的某一行数据提示如下错误:ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

错误提示:正在使用安全更新模式,尝试更新表没有使用键列的where条件;

原因是:mysql有个叫SQL_SAFE_UPDATES的变量,为了数据库更新操作的安全性,此值默认为1,所以才会出现更新失败的情况。

举例如下:

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

查看设置:

mysql> show variables like ‘sql_safe%‘;
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| sql_safe_updates | ON    |
+------------------+-------+

下面是SQL_SAFE_UPDATES变量为0和1时的取值说明:

SQL_SAFE_UPDATES有两个取值0和1, 或ON 和OFF;

SQL_SAFE_UPDATES = 1,ON时,不带where和limit条件的update和delete操作语句是无法执行的,即使是有where和limit条件但不带key column的update和delete也不能执行。

SQL_SAFE_UPDATES =0,OFF时,update和delete操作将会顺利执行。那么很显然,此变量的默认值是1。

所以,出现1175错误的时候,可以先设置SQL_SAFE_UPDATES的值为0 OFF,然后再执行更新;

以下2条命令都可以;

mysql> set sql_safe_updates=0; 

mysql> set sql_safe_updates=off;    

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)

更改只在当前生效,退出mysql,再次登录后恢复为默认。

时间: 2024-11-08 19:11:17

mysql错误:ERROR 1175: You are using safe update mode 解决方法的相关文章

mysql错误:Error Code: 1175. You are using safe update mode and you tried to update a table……

今天遇到一个mysql错误: 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 Queries and reconnect. 网上查了一下,原来是SET SQL_SAFE_UPDATES

Mysql 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

今天用mysql workbench在更新数据的时候,出现了下面错误:15:52:39    update wp_posts set post_content = replace(post_content, '/water', '')    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 disabl

Error Code: 1175 You are using safe update mode and you tried to update a table without a WHERE that

转载自: http://blog.csdn.net/amohan/article/details/9980315 快速高效用:SET SQL_SAFE_UPDATES = 0:下面的就不要看了! 今日用MySQL Workbench进行数据库的管理更新时,执行一个更新的语句碰到以下错误提示: Error Code: 1175 You are using safe update mode and you tried to update a table without a WHERE that us

Error Code: 1175. You are using safe update mode and you tried to ......

MySQL提示的错误信息: 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 意思是:在安全更新模式下尝试使用未带关键字的“WHERE”语句,在Preference中切换该选项. SET SQL_SA

Error Code: 1175. You are using safe update

在使用mysql执行update的时候,如果不是用主键当where语句,会报如下错误,使用主键用于where语句中正常. 异常内容: 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 Q

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE

1 错误描写叙述 19:15:34 call sp_store_insert(90) 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. 0.0

Error Code: 1175. You are using safe update mode and you tried to update a table

错误描述 11:14:39 delete from t_analy_yhd 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. 0.000 se

NDK开发中出现各种Semantic Error“XXX 'xxx' could not be resolved”的解决方法

项目要求NDK开发App程序,于是import了工程项目,搭好了环境,结果出现各种 Type 'xxx' could not be resolved Method 'xxx' could not be resolved 等等Semantic Error.但是工程本身并不存在错误,可以成功编译. 解决方法:明显是没有包含各种头文件造成的,<jni.h>这些头文件包含进工程即可. 右键工程->Properties->C/C++ General->Paths and Symbols

golang github.com/go-sql-driver/mysql 遇到的数据库,设置库设计不合理的解决方法

golang github.com/go-sql-driver/mysql 遇到的数据库,设置库设计不合理的解决方法,查询中报了以下这个错 Scan error on column index 2: unsupported Scan, storing driver.Value type <nil> 解决方案就是动态的把数据 字段前加一上一个COALESCE SELECT u.id,ta.`title` as `活动名` ,COALESCE(IFNULL(i.name,i.nickname) F