第二步,停掉MySQL
[root@serv01 ~]# /etc/init.d/mysqld stop Shutting down MySQL... SUCCESS!
第三步,創(chuàng)建備份目錄,并修改擁有者和所屬組
[root@serv01 ~]# mkdir /databackup [root@serv01 ~]# chown mysql.mysql /databackup/ -R [root@serv01 ~]# ll /databackup/ -d drwxr-xr-x. 2 mysql mysql 4096 Sep 10 17:46 /databackup/ [root@serv01 ~]# cd /databackup/
第四步,冷備(使用tar命令)
[root@serv01 databackup]# tar -cvPzf mysql01.tar.gz
第五步,測(cè)試?yán)鋫涞臄?shù)據(jù)是否正常,我們刪除掉data下的所有數(shù)據(jù)
[root@serv01 databackup]# rm -rf /usr/local/mysql/data/*
第六步,刪除所有數(shù)據(jù)后數(shù)據(jù)庫(kù)不能啟動(dòng)
[root@serv01 databackup]# /etc/init.d/mysqld start Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/serv01.host.com.pid).
第七步,恢復(fù)數(shù)據(jù)(使用tar命令)
[root@serv01 databackup]# tar -xvPf mysql01.tar.gz
第八步,啟動(dòng)MySQL,然后登錄MySQL,查看數(shù)據(jù)是否丟失,如果數(shù)據(jù)正常代表冷備成功
[root@serv01 databackup]# /etc/init.d/mysqld start Starting MySQL.. SUCCESS! [root@serv01 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.29-log Source distribution Copyright (c) 2000, 2012, 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> use larrydb; Database changed mysql> select * from class; +------+--------+ | cid | cname | +------+--------+ | 1 | linux | | 2 | oracle | +------+--------+ 2 rows in set (0.00 sec) mysql> select * from stu; +------+---------+------+ | sid | sname | cid | +------+---------+------+ | 1 | larry01 | 1 | | 2 | larry02 | 2 | +------+---------+------+ 2 rows in set (0.00 sec)
我的郵箱:wgbno27@163.com 新浪微博:@justdb 微信公眾平臺(tái):JustOracle(微信號(hào):justoracle) 數(shù)據(jù)庫(kù)技術(shù)交流群:336882565(加群時(shí)驗(yàn)證 From CSDN XXX) All is well 2013年11月2日 By Larry Wen
![]() |
![]() ![]() |
@Wentasy |
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com