Home > Database > Mysql Tutorial > body text

What does mysql safe mode mean?

藏色散人
Release: 2020-09-19 13:46:54
Original
2904 people have browsed it

What does mysql safe mode mean?

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)
Copy after login

The above query command example indicates the current mysql is in safe mode.

set sql_safe_updates=1;  //安全模式打开状态
set sql_safe_updates=0;  //安全模式关闭状态
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template