update sales set city = '上海'where city = 'shanghai'; 这条语句报出 如下错误
update sales set city = '上海'where city = 'shanghai' Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
解决方案直接如下图

update sales set city = '上海'where city = 'shanghai';
show global variables like '%sql_safe_updates';
set global sql_safe_updates = 0;
将global 的变量sql_safe_updates = 0即可,mysql8.0默认是off状态
文章描述了一条SQL更新语句在执行时遇到的1175错误,该错误是因为在安全更新模式下尝试更新表而没有使用键列。解决方案是关闭全局变量sql_safe_updates,将其设置为0,以允许不基于键的更新操作。在MySQL8.0中,此变量默认为关闭状态。
311

被折叠的 条评论
为什么被折叠?



