MySQL備份與恢複之冷備

來源:互聯網
上載者:User

用一句話概括冷備,就是把資料庫服務,比如MySQL,Oracle停下來,然後使用拷貝、打包或者壓縮命令對資料目錄進行備份。如果資料出現異常,則可以通過備份資料恢複。冷備一般需要定製計劃,比如什麼時候做備份,每次對哪些資料進行備份等等。但是由於這樣的備份佔用過多的空間,對大資料量的環境下不一定適合,故生產環境很少使用。 

 

二 冷備

三 冷備實驗

 

第一步,建立測試資料庫,插入測試資料

mysql> use larrydb;Database changedmysql> show tables;+-------------------+| Tables_in_larrydb |+-------------------+| access            |+-------------------+1 row in set (0.00 sec)mysql> drop table access;Query OK, 0 rows affected (0.00 sec)mysql> clearmysql> show tables;Empty set (0.00 sec)mysql> mysql> create table class(    -> cid int,    -> cname varchar(30));Query OK, 0 rows affected (0.01 sec)mysql> show create table class \G;*************************** 1. row ***************************       Table: classCreate Table: CREATE TABLE `class` (  `cid` int(11) DEFAULT NULL,  `cname` varchar(30) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin11 row in set (0.00 sec)ERROR: No query specifiedmysql> create table stu(    -> sid int,    -> sname varchar(30),    -> cid int) engine=myisam;Query OK, 0 rows affected (0.00 sec)mysql> show create table stu \G;*************************** 1. row ***************************       Table: stuCreate Table: CREATE TABLE `stu` (  `sid` int(11) DEFAULT NULL,  `sname` varchar(30) DEFAULT NULL,  `cid` int(11) DEFAULT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf81 row in set (0.00 sec)ERROR: No query specifiedmysql> insert into class values(1,'linux'),(2,'oracle');Query OK, 2 rows affected (0.00 sec)Records: 2  Duplicates: 0  Warnings: 0mysql> desc class;+-------+-------------+------+-----+---------+-------+| Field | Type        | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+-------+| cid   | int(11)     | YES  |     | NULL    |       || cname | varchar(30) | YES  |     | NULL    |       |+-------+-------------+------+-----+---------+-------+2 rows in set (0.00 sec)mysql> desc stu;+-------+-------------+------+-----+---------+-------+| Field | Type        | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+-------+| sid   | int(11)     | YES  |     | NULL    |       || sname | varchar(30) | YES  |     | NULL    |       || cid   | int(11)     | YES  |     | NULL    |       |+-------+-------------+------+-----+---------+-------+3 rows in set (0.00 sec)mysql> insert into stu values(1,'larry01',1),(2,'larry02',2);Query OK, 2 rows affected (0.00 sec)Records: 2  Duplicates: 0  Warnings: 0mysql> select * from stu;+------+---------+------+| sid  | sname   | cid  |+------+---------+------+|    1 | larry01 |    1 ||    2 | larry02 |    2 |+------+---------+------+

 

更多詳情見請繼續閱讀下一頁的精彩內容:

MySQL備份和恢複具體實施

MySQL備份:mylvmbackup介紹與使用

Linux下通過mysqldump備份MySQL資料庫成sql檔案

Linux中使用mysqldump對MySQL資料庫進行定時備份  

  • 1
  • 2
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.