久久久久久久性爱潮,国产又粗又猛又爽又黄下载视频,尤物国产在线一区视频,欧美日本国产在线不卡

<sup id="4uqqy"><ol id="4uqqy"></ol></sup>
  • <th id="4uqqy"></th>

      • <strike id="4uqqy"><nobr id="4uqqy"><ins id="4uqqy"></ins></nobr></strike><sup id="4uqqy"></sup><strong id="4uqqy"><u id="4uqqy"></u></strong>
        <sub id="4uqqy"></sub>

          綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門排行|軟件分類|軟件專題|廠商大全

          綠色資源網(wǎng)

          技術(shù)教程
          您的位置:首頁數(shù)據(jù)庫類MySQL → MySQL數(shù)據(jù)庫的自動備份與數(shù)據(jù)庫被破壞后的恢復(fù)

          MySQL數(shù)據(jù)庫的自動備份與數(shù)據(jù)庫被破壞后的恢復(fù)

          我要評論 2015/02/23 11:52:20 來源:綠色資源網(wǎng) 編輯:綠色資源站 [ ] 評論:0 點擊:508次

          一、前言:

          當(dāng)數(shù)據(jù)庫服務(wù)器建立好以后,我們首先要做的不是考慮要在這個支持?jǐn)?shù)據(jù)庫的服務(wù)器運行哪些受MySQL提攜的程序,而是當(dāng)數(shù)據(jù)庫遭到破壞后,怎樣安然恢復(fù)到最后一次正常的狀態(tài),使得數(shù)據(jù)的損失達到最小。

          或者說,僅僅是數(shù)據(jù)庫服務(wù)器的建立,只能說明它能做些什么,并不代表它能穩(wěn)定的做些什么。災(zāi)難恢復(fù)的效率及全面性,也是系統(tǒng)的穩(wěn)定性的一個準(zhǔn)因素,尤其對于一個服務(wù)器系統(tǒng)。

          這一節(jié),介紹數(shù)據(jù)庫自動備份以及數(shù)據(jù)庫被破壞后的恢復(fù)的方法。在這里,我們使用mysqlhotcopy,并且定義一段Shell腳本來實現(xiàn)數(shù)據(jù)庫的自動備份,并且,讓整個數(shù)據(jù)自動備份與數(shù)據(jù)恢復(fù)過程都基于Shell。

          建立數(shù)據(jù)庫備份所需條件

          [1] 建立自動備份腳本

          在這里,為了使數(shù)據(jù)庫備份和恢復(fù)的符合我們的實際要求,用一段符合要求的Shell腳本來實現(xiàn)整個備份過程的自動化。

          [root@CentOS ~]# vi mysql-backup.sh  &larr; 建立數(shù)據(jù)庫自動備份腳本,如下:

          #!/bin/bash

          PATH=/usr/local/sbin:/usr/bin:/bin

          # The Directory of Backup
          BACKDIR=/backup/mysql

          # The Password of MySQL
          ROOTPASS=********  此處請將星號替換成MySQL的root密碼

          # Remake the Directory of Backup
          rm -rf $BACKDIR
          mkdir -p $BACKDIR

          # Get the Name of Database
          DBLIST=`ls -p /var/lib/mysql | grep / | tr -d /`

          # Backup with Database
          for dbname in $DBLIST
          do
          mysqlhotcopy $dbname -u root -p $ROOTPASS $BACKDIR | logger -t mysqlhotcopy
          done

          [2] 運行數(shù)據(jù)庫自動備份腳本

          [root@CentOS ~]# chmod 700 mysql-backup.sh  改變腳本屬性,讓其只能讓root用戶執(zhí)行
          [root@CentOS ~]# ./mysql-backup.sh   運行腳本
          [root@CentOS ~]# ls -l /backup/mysql/   確認(rèn)一下是否備份成功
          total 8
          drwxr-x--- 2 mysql mysql 4096 Sep 1 16:54 mysql   已成功備份到/backup/mysql目錄中

          [3] 讓數(shù)據(jù)庫備份腳本每天自動運行

          [root@sample ~]# crontab -e  &larr; 編輯自動運行規(guī)則(然后會出現(xiàn)編輯窗口,操作同vi)
          00 03 * * * /root/mysql-backup.sh   添加這一行到文件中,讓數(shù)據(jù)庫備份每天凌晨3點進行

          測試自動備份正常運轉(zhuǎn)與否(備份恢復(fù)的方法)

          這里,以通過實際操作的過程來介紹問題出現(xiàn)后的恢復(fù)方法。

          [1] 當(dāng)數(shù)據(jù)庫被刪除后的恢復(fù)方法

          首先建立一個測試用的數(shù)據(jù)庫。

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

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

          mysql> create database test;  &larr; 建立一個測試用的數(shù)據(jù)庫test
          Query OK, 1 row affected (0.00 sec)

          mysql> use test  &larr; 連接到這個數(shù)據(jù)庫
          Database changed

          mysql> create table test(num int, name varchar(50));  &larr; 在數(shù)據(jù)庫中建立一個表
          Query OK, 0 rows affected (0.07 sec)

          mysql> insert into test values(1,'Hello,CentOS');  &larr; 插入一個值到這個表(這里以"Hello,CentOS"為例)
          Query OK, 1 row affected (0.02 sec)

          mysql> select * from test;  &larr; 查看數(shù)據(jù)庫中的內(nèi)容
          +------+-----------------+
          | num | name |
          +------+-----------------+
          |1  | Hello,Centos |  &larr; 確認(rèn)剛剛插入到表中的值的存在
          +------+------------------+
          1 row in set (0.01 sec)

          mysql> exit  &larr; 退出MySQL服務(wù)器
          Bye

          然后,運行剛才建立的數(shù)據(jù)庫備份腳本,備份剛剛建立的測試用的數(shù)據(jù)庫。

          [root@sample ~]# cd &larr; 回到腳本所在的root用戶的根目錄
          [root@sample ~]# ./mysql-backup.sh  &larr; 運行腳本進行數(shù)據(jù)庫備份

          接下來,我們再次登錄到MySQL服務(wù)器中,刪除剛剛建立的測試用的數(shù)據(jù)庫test,以便于測試數(shù)據(jù)恢復(fù)能否成功。

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

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

          mysql> use test  &larr; 連接到測試用的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;  &larr; 刪除數(shù)據(jù)中的表
          Query OK, 0 rows affected (0.04 sec)

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

          mysql> show databases;
          +---------------+
          | Database |
          +---------------+
          | mysql | 

          關(guān)鍵詞:MySQL數(shù)據(jù)庫

          閱讀本文后您有什么感想? 已有 人給出評價!

          • 2 歡迎喜歡
          • 2 白癡
          • 3 拜托
          • 3 哇
          • 2 加油
          • 2 鄙視