Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the skills of preventing human misoperation of MySQL database?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

To prevent human misoperation of MySQL database skills, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Skills of preventing human misoperation of MySQL database

1. Mysql help description

[oldboy_c64] # mysql-- help | grep dummy-U,-- i-am-a-dummy Synonym for option-- safe-updates,-U. I-am-a-dummy FALSE

When you add the option-U to the mysql command, when you issue UPDATE or DELETE without the WHERE or LIMIT keyword, the mysql program refuses to execute

2. Specify-U login test

[oldboy_c64] # mysql-uroot-poldboy123-S / data/3306/mysql.sock-U Welcome 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, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be 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 you tried to update a table without a WHERE that uses a KEY column mysql > quit Bye

Tip: it cannot be deleted without conditions, and the goal can be achieved.

3. Make it an alias to prevent the boss and DBA from misoperation.

[oldboy_c64] # alias mysql='mysql-U'[oldboy_c64] # mysql-uroot-poldboy123-S / data/3306/mysql.sock Welcome 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 WHERE that uses a KEY column mysql > delete from oldboy.student where Sno=5; Query OK, 1 row affected (0.02 sec) mysql > quit Bye [oldboy_c64 ~] # echo "alias mysql='mysql-U'> / etc/profile [oldboy_c64 ~] #. / etc/profile [oldboy_c64 ~] # tail-1 / etc/profile alias mysql='mysql-U'

Conclusion:

After adding the option-U to the mysql command, when issuing UPDATE or DELETE without the WHERE or LIMIT keyword, the mysql program refuses to execute

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report