1、Error Code: 1175
SQL语句 : update myapp.Posts set niceCount=0;
今天在执行mysql uodate语句时发现,明明SQL写的是正确的,但就是报错,具体错误如下:
12:07:24 update myapp.Posts set niceCount=0 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 sec
复制代码
也就是说mysql默认运行在safe模式下,当你执行update语句时,必须提供一个主键的where
条件时才能正确执行update
语句。
我们可以通过将mysql的运行模式改为non-safe
,修改如下:
SET SQL_SAFE_UPDATES = 0;
同时也可以更改为safe
模式:
SET SQL_SAFE_UPDATES = 1;