一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數據庫技術|

服務器之家 - 數據庫 - Mysql - MySQL數據庫防止人為誤操作的實例講解

MySQL數據庫防止人為誤操作的實例講解

2020-04-06 14:20shichen2014 Mysql

這篇文章主要介紹了MySQL數據庫防止人為誤操作的方法,需要的朋友可以參考下

有不少開發人員在操作MySQL數據庫的時候都遇到過誤操作的情況,例如更新數據庫的時候update語句忘記加上where條件,就會造成極為悲劇的結果。本文就針對防止MySQL數據庫誤操作的方法做出如下詳解:

1、mysql幫助說明

?
1
2
3
# 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登錄測試

?
1
2
3
4
5
6
7
8
9
10
11
12
13
# 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誤操作

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 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程序拒絕執行

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日本人成年视频在线观看 | 波多野结衣在线观看视频 | 亚洲精品在看在线观看 | 女bbbbxxxx视频| 美女扒开胸罩露出奶 | 国产一级在线观看 | chinese男同志同性twink | 99热最新 | s8sp加密路线和免费路线首页 | 天仙tv微福视频 | 九九久久国产精品大片 | 日本精品欧洲www | 人人做人人爽人人爱 | 偷拍自拍校园春色 | 午夜一区二区免费视频 | 午夜久久久久久网站 | 久久精品国产在热亚洲完整版 | 成年人在线免费看 | 娜娜啪| 亚洲 日本 中文字幕 制服 | 超级毛片 | 3d动漫被吸乳羞羞 | 男人狂躁女人下半身 | 嫩草影院永久一二三入口 | 亚洲码和乱人伦中文一区 | 亚洲色图亚洲色图 | 67194最新网址 | 国产午夜精品久久久久 | 成人中文字幕在线观看 | 青草网在线观看 | 亚洲精品视频在线免费 | 四虎永久| 特黄特黄aaaa级毛片免费看 | 国产剧情麻豆刘玥视频 | 国产精品永久免费视频观看 | 亚洲人成毛片线播放 | 国产日韩欧美在线一区二区三区 | 国产精品福利在线观看秒播 | 欧美极品摘花过程 | 99精品久久精品一区二区 | 草草影院永久在线观看 |