sPDNe1.jpg

mysql安全锁,官方文档说明:

If set to 1, MySQL aborts UPDATE or DELETE statements that do not use a key in the WHERE clause or a LIMIT clause. (Specifically, UPDATE statements must have a WHERE clause that uses a key or a LIMIT clause, or both. DELETE statements must have both.) This makes it possible to catch UPDATE or DELETE statements where keys are not used properly and that would probably change or delete a large number of rows. The default value is 0.

开启后update和delete必须要带where或者limit限制行数,否则报错
负面作用就是更改某些配置时会失败。

配置方法:

SHOW VARIABLES LIKE 'sql_safe_updates'
SET sql_safe_updates=1; --当前连接中有效
SET global sql_safe_updates=1; --所有连接有效,重启mysql后失效
sql_safe_updates=1;   --永久生效

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code