日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL數(shù)據(jù)庫被修改后的恢復方法

MySQL數(shù)據(jù)庫的恢復,之前已經(jīng)為大家介紹了MySQL數(shù)據(jù)庫中數(shù)據(jù)被刪除后的恢復,本文為大家介紹另外一種恢復的情況,即MySQL數(shù)據(jù)庫被修改后的恢復。

當數(shù)據(jù)庫被修改后的恢復方法:

數(shù)據(jù)庫被修改,可能存在著多方面的原因,被入侵、以及相應程序存在Bug等等,這里不作詳細介紹。這里將只介紹在數(shù)據(jù)庫被修改后,如果恢復到被修改前狀態(tài)的方法。

具體和上面所述的“數(shù)據(jù)庫被刪除后的恢復方法”相類似。這里,測試用數(shù)據(jù)庫接著使用剛剛在前面用過的test。這里為了使剛剛接觸數(shù)據(jù)庫的朋友不至于理解混亂,我們再次登錄到MySQL服務器上確認一下剛剛建立的測試用的數(shù)據(jù)庫test的相關信息。

[root@CentOS ~]# mysql -u root -p  ← 用root登錄到MySQL服務器
Enter password:  ← 輸入MySQL的root用戶密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;  ← 查看當前存在的數(shù)據(jù)庫
+-------------+
| Database |
+-------------+
| mysql |
| test  |
+------------+
2 rows in set (0.00 sec)

mysql> use test  ← 連接到test數(shù)據(jù)庫
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;  ← 查看test數(shù)據(jù)庫中存在的表
+-------------------+
| Tables_in_test |
+-------------------+
| test  |
+-------------------+
1 row in set (0.00 sec)

mysql> select * from test;  ← 查看數(shù)據(jù)庫中的內容
+------+--------------------+
| num | name  |
+------+--------------------+
| 1 | Hello,CentOS|
+------+--------------------+
1 row in set (0.01 sec)

mysql> exit  ← 退出MySQL服務器
Bye

然后,我們再次運行數(shù)據(jù)庫備份腳本,將當前狀態(tài)的數(shù)據(jù)庫,再做一次備份。

[root@CentOS ~]# cd  ← 回到腳本所在的root用戶的根目錄
[root@CentOS ~]# ./mysql-backup.sh  ← 運行腳本進行數(shù)據(jù)庫備份
接下來,我們再次登錄到MySQL服務器中,對測試用的數(shù)據(jù)庫test進行一些修改,以便于測試數(shù)據(jù)恢復能否成功。

[root@sample ~]# mysql -u root -p  ← 用root登錄到MySQL服務器
Enter password:  ← 輸入MySQL的root用戶密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test  ← 連接到test數(shù)據(jù)庫
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update test set name='Shit,Windows';  ← 然后將test中表的值重新定義為“Shit,Windows”(原來為“Hello,CentOS”)
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from test;  ← 確認test中的表被定義的值
+------+--------------------+
| num | name  |
+------+-------------------+
| 1 | Shit,Windows |  ← 確認已經(jīng)將原test數(shù)據(jù)庫表中的值修改為新的值“Shit,Windows”
+------+-------------------+
1 row in set (0.00 sec)

mysql> exit  ← 退出MySQL服務器
Bye

以上,我們就等于模擬了數(shù)據(jù)庫被篡改的過程。接下來,是數(shù)據(jù)庫被“篡改”后,用備份進行恢復的方法。

[root@CentOS ~]# /bin/cp -Rf /backup/mysql/test/ /var/lib/mysql/  ← 復制備份的數(shù)據(jù)庫test到相應目錄

然后,再次登錄到MySQL服務器上,看數(shù)據(jù)庫是否被恢復到了被“篡改”之前的狀態(tài)。

[root@CentOS ~]# mysql -u root -p  ← 用root登錄到MySQL服務器
Enter password:  ← 輸入MySQL的root用戶密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test  ← 連接到test數(shù)據(jù)庫
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from test;  ← 查看數(shù)據(jù)庫中的內容
+------+----------------+
| num | name  |
+------+----------------+
| 1| Hello,CentOS | ← 確認數(shù)據(jù)表中的內容與被修改前定義的“Hello,CentOS”一樣!
+------+----------------+
1 row in set (0.01 sec)

mysql> exit  ← 退出MySQL服務器
Bye

以上結果表示,數(shù)據(jù)庫被修改后,用備份后的數(shù)據(jù)庫成功的將數(shù)據(jù)恢復到了被“篡改”前的狀態(tài)。

測試后…

測試完成后,將測試用過的遺留信息刪除。

[root@CentOS ~]# mysql -u root -p  ← 用root登錄到MySQL服務器
Enter password:  ← 輸入MySQL的root用戶密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test  ← 連接到test數(shù)據(jù)庫
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> drop table test;  ← 刪除test數(shù)據(jù)庫中的表
Query OK, 0 rows affected (0.01 sec)

mysql> drop database test;  ← 刪除測試用數(shù)據(jù)庫test
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;  ← 查看當前存在的數(shù)據(jù)庫
+-------------+
| Database |
+-------------+
| mysql |  ← 確認測試用數(shù)據(jù)庫test不存在、已被刪除
+-------------+
1 row in set (0.00 sec)

mysql> exit  ← 退出MySQL服務器
Bye

如果大家以后在工作中遇到MySQL數(shù)據(jù)庫被修改,通過本文的學習,到時候就能很輕松的應對,利用上文中介紹的進行數(shù)據(jù)庫的恢復。


文章名稱:MySQL數(shù)據(jù)庫被修改后的恢復方法
地址分享:http://m.5511xx.com/article/cdijsgd.html