You must have heard that some developers, due to personal mistakes, did not add a where clause when deleting or updating statements, resulting in confusion in the entire table data. MySQL safe mode: MySQL will report an error when it finds that the delete or update statement does not have a where or limit condition. The entire SQL statement will not be executed, effectively preventing the accidental deletion of tables. Safe Mode SettingsCheck the status in mysql using the following command: show variables like 'sql_safe_updates'; The default state is OFF, just set the state to ON:
After setting to ON
testTest in safe mode 1. Update and delete without where clause delete from t_user > 1175 - You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column > Time: 0.001s
update t_user set name='123' > 1175 - You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column > Time: 0.001s 2. Delete of non-index keys delete from t_user where name='123' > 1175 - You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column > Time: 0.007s If the where condition of delete is not an index key, you must add a limit. delete from t_user where name='123' limit 1 > Affected rows: 0 > Time: 0.002s 3. Delete index key delete from t_user where group_id='123' > Affected rows: 0 > Time: 0s Summarize If
The
This is the end of this article about how to effectively prevent MySQL from deleting databases. For more information about preventing MySQL from deleting databases, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of the setting of background-image attribute in HTML
>>: Detailed explanation of tinyMCE usage and experience
01. Command Overview Linux provides a rich help m...
1. Font properties color, specifies the color of ...
Table of contents Million-level data processing s...
Table of contents Install vim plugin manager Add ...
Mysql is a popular and easy-to-use database softw...
Preface The best method may not be the one you ca...
question For a given MySQL connection, how can we...
Preface By default, MySQL will initialize a large...
The default time type (datetime and timestamp) in...
MySQL full-text index is a special index that gen...
Table of contents Overview Canvas API: Drawing Gr...
We often encounter this situation when doing devel...
Fault site: Log in to the MySQL server and get th...
First, open the virtual machine Open xshell5 to c...
The vue project implements an upgraded version of...