MySQL数据库防止人为误操作的实例讲解_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL数据库防止人为误操作的实例讲解_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1883字,纯文字阅读大概需要3分钟。
内容图文
![MySQL数据库防止人为误操作的实例讲解_MySQL](/upload/InfoBanner/zyjiaocheng/579/440a0c60f5674cd3b019c92cda2b343e.jpg)
1、mysql帮助说明
# mysql --help|grep dummy -U, --i-am-a-dummy Synonym for option --safe-updates, -U. i-am-a-dummy FALSE
在mysql命令加上选项-U后,当发出没有WHERE或LIMIT关键字的UPDATE或DELETE时,mysql程序就会拒绝执行
2、指定-U登录测试
# 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
提示:此处不加条件无法删除,目的达到。
3、做成别名防止DBA误操作
# 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 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 # echo "alias mysql='mysql -U'" >>/etc/profile # . /etc/profile # tail -1 /etc/profile alias mysql='mysql -U'
结论:在mysql命令加上选项-U后,当发出没有WHERE或LIMIT关键字的UPDATE或DELETE时,mysql程序拒绝执行
内容总结
以上是互联网集市为您收集整理的MySQL数据库防止人为误操作的实例讲解_MySQL全部内容,希望文章能够帮你解决MySQL数据库防止人为误操作的实例讲解_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。