An example of the MySQL database technique to prevent human misoperation (this is an internal student problem trained by the old boy, which is a database security technique). A few years ago, the old boy personally encountered a "Murder Case" and the boss logged on to the database to update 1.
An example of the MySQL database technique to prevent human misoperation (this is an internal student problem trained by the old boy, which is a database security technique). A few years ago, the old boy personally encountered a "Murder Case" and the boss logged on to the database to update 1.
A Case Study of MySQL database techniques to prevent human misoperation
(This question is from internal student training by old boys. It is a database security technique)
A few years ago, the old boy personally encountered a "Murder Case". The boss logged on to the database to update a record and forgot to add the where record, so the tragedy occurred, this allows me to be more familiar with MySQL incremental recovery than other knowledge points. At the same time, I am very concerned about internal database security. Every time I talk about this, I will tell the students the story of this leadership.
1. mysql help
[Oldboy_c64 ~] # Mysql -- help | grep dummy-U, -- I-am-a-dummy Synonym for option -- safe-updates,-U. I-am-a-dummyFALSE
After the option-U is added to the mysql Command, the mysql program will refuse to execute the UPDATE or DELETE statement without the WHERE or LIMIT keyword.
2. Specify-U for Logon Test
[Oldboy_c64 ~] # Mysql-uroot-poldboy123-S/data/3306/mysql. sock-UWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 14 Server version: 5.5.32-log MySQL Community Server (GPL) Copyright (c) 2000,201 3, Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners. type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql> delete from oldboy. student; ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY columnmysql> quitBye
Tip: deletion is not allowed without any conditions. The goal is achieved.
3. Create an alias to avoid misoperation of the old and DBA
[Oldboy_c64 ~] # Alias mysql = 'mysql-U' [oldboy_c64 ~] # Mysql-uroot-poldboy123-S/data/3306/mysql. sockWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 15 Server version: 5.5.32-log MySQL Community Server (GPL) Type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql> delete from oldboy. student; ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHE RE that uses a KEY columnmysql> delete from oldboy. student where Sno = 5; Query OK, 1 row affected (0.02 sec) mysql> quitBye [oldboy_c64 ~] # Echo "alias mysql = 'mysql-U'">/etc/profile [oldboy_c64 ~] #./Etc/profile [oldboy_c64 ~] # Tail-1/etc/profilealias mysql = 'mysql-U'
Conclusion:
After the option-U is added to the mysql Command, the mysql program rejects execution when an UPDATE or DELETE statement without the WHERE or LIMIT keyword is sent.
This article is from the "old boy linux O & M" blog. Please keep this source