新聞中心
前文提到,本書的技術(shù)主線是Linux系統(tǒng)的運維方向,不會對數(shù)據(jù)庫管理系統(tǒng)的操作進行深入的講解,因此大家掌握了上面這些基本的數(shù)據(jù)庫操作命令之后就足夠了。下面要講解的是數(shù)據(jù)庫的備份以及恢復(fù),這些知識比較實用,希望大家能夠掌握。

成都創(chuàng)新互聯(lián)一直通過網(wǎng)站建設(shè)和網(wǎng)站營銷幫助企業(yè)獲得更多客戶資源。 以"深度挖掘,量身打造,注重實效"的一站式服務(wù),以網(wǎng)站設(shè)計、成都網(wǎng)站設(shè)計、移動互聯(lián)產(chǎn)品、成都營銷網(wǎng)站建設(shè)服務(wù)為核心業(yè)務(wù)。十余年網(wǎng)站制作的經(jīng)驗,使用新網(wǎng)站建設(shè)技術(shù),全新開發(fā)出的標(biāo)準(zhǔn)網(wǎng)站,不但價格便宜而且實用、靈活,特別適合中小公司網(wǎng)站制作。網(wǎng)站管理系統(tǒng)簡單易用,維護方便,您可以完全操作網(wǎng)站資料,是中小公司快速網(wǎng)站建設(shè)的選擇。
mysqldump命令用于備份數(shù)據(jù)庫數(shù)據(jù),格式為“mysqldump [參數(shù)] [數(shù)據(jù)庫名稱]”。其中參數(shù)與mysql命令大致相同,-u參數(shù)用于定義登錄數(shù)據(jù)庫的賬戶名稱,-p參數(shù)代表密碼提示符。下面將linuxprobe數(shù)據(jù)庫中的內(nèi)容導(dǎo)出成一個文件,并保存到root管理員的家目錄中:
[root@linuxprobe ~]# mysqldump -u root -p linuxprobe > /root/linuxprobeDB.dump
Enter password:此處輸入root管理員在數(shù)據(jù)庫中的密碼然后進入MariaDB數(shù)據(jù)庫管理系統(tǒng),徹底刪除linuxprobe數(shù)據(jù)庫,這樣mybook數(shù)據(jù)表單也將被徹底刪除。然后重新建立linuxprobe數(shù)據(jù)庫:
MariaDB [(none)]> DROP DATABASE linuxprobe;
Query OK, 1 row affected (0.04 sec)
MariaDB [(none)]> SHOW databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.02 sec)
MariaDB [(none)]> CREATE DATABASE linuxprobe;
Query OK, 1 row affected (0.00 sec)接下來是見證數(shù)據(jù)恢復(fù)效果的時刻!使用輸入重定向符把剛剛備份的數(shù)據(jù)庫文件導(dǎo)入到mysql命令中,然后執(zhí)行該命令。接下來登錄到MariaDB數(shù)據(jù)庫,就又能看到linuxprobe數(shù)據(jù)庫以及mybook數(shù)據(jù)表單了。數(shù)據(jù)庫恢復(fù)成功!
[root@linuxprobe ~]# mysql -u root -p linuxprobe < /root/linuxprobeDB.dump
Enter password: 此處輸入root管理員在數(shù)據(jù)庫中的密碼值
[root@linuxprobe ~]# mysql -u root -p
Enter password: 此處輸入root管理員在數(shù)據(jù)庫中的密碼值
MariaDB [(none)]> use linuxprobe;
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
MariaDB [linuxprobe]> SHOW tables;
+----------------------+
| Tables_in_linuxprobe |
+----------------------+
| mybook |
+----------------------+
1 row in set (0.05 sec)
MariaDB [linuxprobe]> DESCRIBE mybook;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name | char(15) | YES | | NULL | |
| price | int(11) | YES | | NULL | |
| pages | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.02 sec) 網(wǎng)站標(biāo)題:創(chuàng)新互聯(lián)linux教程:18.6數(shù)據(jù)庫的備份及恢復(fù)
網(wǎng)頁URL:http://www.dlmjj.cn/article/djejhsd.html


咨詢
建站咨詢
