What is safe mode? What does mysql safe mode mean?
In mysql, if there is no where condition in update and delete, all data will be modified. Not only developers who are new to MySQL will encounter this problem, but engineers with certain work experience will inevitably forget to write the where condition. In order to avoid all data modification and deletion caused by mistakes, the safe mode of mysql can be turned on.
Opening and closing the security mode
After connecting to the database, check the status of the current mysql security mode
mysql> show variables like 'sql_safe_updates'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | sql_safe_updates | ON | +------------------+-------+ 1 row in set (0.00 sec)
The above query command example indicates the current mysql is in safe mode.
set sql_safe_updates=1; //安全模式打开状态 set sql_safe_updates=0; //安全模式关闭状态
In the update operation: When the column (column) in the where condition has no index available and no limit limit, the update will be rejected. Updates will be rejected when the where condition is constant and there is no limit.
In the delete operation: Refuse to delete when ①where condition is a constant, ②or where condition is empty, ③or when there is no index available for the column (column) in the where condition and there is no limit limit.
Related learning recommendations: mysql database
The above is the detailed content of What does mysql safe mode mean?. For more information, please follow other related articles on the PHP Chinese website!