A lot of developers in the operation of the MySQL database has been a misuse of the situation, such as updating the database when the UPDATE statement forgot to add where conditions, it will cause extremely tragic results. This article in order to prevent the MySQL database error operation method to make the following detailed explanation:
1, MySQL help instructions
# mysql--help|grep dummy-
u,--i-am-a-dummy synonym for option--safe-updates,-U.
I-am-a-dummy FALSE
After the MySQL command plus option-u, when an update or delete without a where or limit keyword is issued, the MySQL program refuses to execute
2. Specify-u login Test
# mysql-uroot-poldboy123-s/data/3306/mysql.sock-u
Welcome to the MySQL monitor. Commands End With; or \g.
Your MySQL Connection ID
is server version:5.5.32-log mysql Community Server (GPL)
Copyright (c), 2013, O Racle and/or its affiliates. All rights reserved.
Oracle is a registered trademark to Oracle Corporation and/or its
affiliates. The other names may is trademarks of their respective
owners.
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 your tried to update a table without a WHERE that uses a KEY column< C11/>mysql> quit
Bye
Hint: The condition cannot be deleted here, the purpose is achieved.
3, to make aliases to prevent DBA error operation
# alias Mysql= ' Mysql-u '
# mysql-uroot-poldboy123-s/data/3306/mysql.sock
Welcome to the MySQL monitor. Commands End With; or \g.
Your MySQL connection ID is
server version:5.5.32-log mysql Community server (GPL)
Type ' help; ' or ' \h ' to He Lp. Type ' \c ' to clear the current input statement.
Mysql> Delete from oldboy.student;
ERROR 1175 (HY000): You are using Safe update mode and your tried to update a table without a WHERE that uses a KEY column< C8/>mysql> Delete from oldboy.student where sno=5;
Query OK, 1 row affected (0.02 sec)
mysql> quit
Bye
# echo "Alias mysql= ' Mysql-u '" >>/etc/profile
#/etc/profile
# tail-1/etc/profile
alias mysql= ' Mysql-u '
Conclusion: after the MySQL command plus option-u, when an update or delete without a where or limit keyword is issued, the MySQL program refuses to execute