国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

Mysql實(shí)現(xiàn)增量恢復(fù)的方法詳解

來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 20:25:25
文檔

Mysql實(shí)現(xiàn)增量恢復(fù)的方法詳解

Mysql實(shí)現(xiàn)增量恢復(fù)的方法詳解:實(shí)驗(yàn)介紹 增量恢復(fù)一般適用的場(chǎng)景: 1、人為的sql語(yǔ)句破壞了數(shù)據(jù)庫(kù) 2、在進(jìn)行下一次完全備份之前發(fā)生系統(tǒng)故障導(dǎo)致數(shù)據(jù)庫(kù)數(shù)據(jù)丟失 3、在主從架構(gòu)中,主庫(kù)數(shù)據(jù)發(fā)生了故障 丟失完全備份之后更改的數(shù)據(jù)的恢復(fù)步驟 1、首先做一個(gè)完全備份,確保生成完全備份的sq
推薦度:
導(dǎo)讀Mysql實(shí)現(xiàn)增量恢復(fù)的方法詳解:實(shí)驗(yàn)介紹 增量恢復(fù)一般適用的場(chǎng)景: 1、人為的sql語(yǔ)句破壞了數(shù)據(jù)庫(kù) 2、在進(jìn)行下一次完全備份之前發(fā)生系統(tǒng)故障導(dǎo)致數(shù)據(jù)庫(kù)數(shù)據(jù)丟失 3、在主從架構(gòu)中,主庫(kù)數(shù)據(jù)發(fā)生了故障 丟失完全備份之后更改的數(shù)據(jù)的恢復(fù)步驟 1、首先做一個(gè)完全備份,確保生成完全備份的sq

3、在數(shù)據(jù)庫(kù)中插入一條記錄,再執(zhí)行flush-logs操作,生成新的二進(jìn)制增量備份文件。

mysql> insert into yx(name,score) values('tom',87);
Query OK, 1 row affected (0.00 sec)

mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
| tom      |  87.00 |
+----------+--------+
5 rows in set (0.00 sec)
[root@promote data]# mysqladmin -u root -p flush-logs  #生成二進(jìn)制文件
Enter password:
[root@promote data]# ls
auto.cnf        ibdata1      ib_logfile1  mysql             mysql-bin.000002  performance_schema  test
ib_buffer_pool  ib_logfile0  ibtmp1       mysql-bin.000001  mysql-bin.index   sys

4、用delete刪除剛才插入的數(shù)據(jù)。模擬完全備份后數(shù)據(jù)丟失。

mysql> delete from yx where name='tom';
Query OK, 1 row affected (0.00 sec)

mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
+----------+--------+
4 rows in set (0.00 sec)

5、使用二進(jìn)制文件進(jìn)行恢復(fù)操作

[root@promote data]# mysqlbinlog --no-defaults mysql-bin.000001 | mysql -u root -p

6、查看數(shù)據(jù)庫(kù)內(nèi)容,刪除的數(shù)據(jù)有了。說(shuō)明數(shù)據(jù)恢復(fù)成功。

mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
| tom      |  87.00 |
+----------+--------+
5 rows in set (0.00 sec)

完全備份之后丟失所有數(shù)據(jù)的恢復(fù)步驟

1、使用drop刪除表yx,模擬數(shù)據(jù)完全丟失

mysql> drop table yx;
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
Empty set (0.00 sec)

2、先使用mysql命令進(jìn)行完全備份恢復(fù)操作。

[root@promote data]# mysql -u root -p test < /opt/test.sql
mysql> use test;
Database changed
mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
+----------+--------+
4 rows in set (0.00 sec)

3、使用二進(jìn)制文件進(jìn)行增量備份操作。

[root@promote data]# mysqlbinlog --no-defaults mysql-bin.000001 | mysql -u root -p
mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
| tom      |  87.00 |
+----------+--------+
5 rows in set (0.00 sec)

基于時(shí)間點(diǎn)與位置的恢復(fù)

利用二進(jìn)制日志實(shí)現(xiàn)局域時(shí)間點(diǎn)與位置的恢復(fù),假如需要往數(shù)據(jù)庫(kù)中插入兩條數(shù)據(jù),但是由于誤操作,兩條插入語(yǔ)句中間刪除一條數(shù)據(jù),而這條數(shù)據(jù)不應(yīng)該刪除,這時(shí)候,需要基于時(shí)間點(diǎn)與位置進(jìn)行恢復(fù)。

–start-datetime=datetime

從二進(jìn)制日志中第1個(gè)日期時(shí)間等于或晚于datetime參量的事件開(kāi)始讀。

–stop-datetime=datetime
從二進(jìn)制日志中第1個(gè)日期時(shí)間等于或晚于datetime參量的事件起停止讀。

–start-position=N
從二進(jìn)制日志中第1個(gè)位置等于N參量時(shí)的事件開(kāi)始讀。

–stop-position=N
從二進(jìn)制日志中第1個(gè)位置等于和大于N參量時(shí)的事件起停止讀。

mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
+----------+--------+
5 rows in set (0.00 sec)

mysql> insert into yx values('test01',87);
Query OK, 1 row affected (0.00 sec)

mysql> delete from yx where name='zhangsan';
Query OK, 1 row affected (0.00 sec)

mysql> insert into yx values('test02',99);
Query OK, 1 row affected (0.17 sec)

mysql> select * from yx;
+---------+-------+
| name    | score |
+---------+-------+
| lisi    | 90.00 |
| wangwu  | 80.00 |
| zhaoliu | 99.00 |
| test01  | 87.00 |
| test02  | 99.00 |
+---------+-------+
6 rows in set (0.00 sec)

1、基于時(shí)間點(diǎn)的恢復(fù)。18-07-03 21:56:04是錯(cuò)誤語(yǔ)句節(jié)點(diǎn),18-07-03 21:56:11第二句正確語(yǔ)句節(jié)點(diǎn)

[root@promote data]# mysqlbinlog --no-defaults --base64-output=decode-rows mysql-bin.000003
# at 298
#180703 21:55:35 server id 1  end_log_pos 406 CRC32 0x257c67ab  Query   thread_id=46    exec_time=0 error_code=0
use `test`/*!*/;
SET TIMESTAMP=1530626135/*!*/;
insert into yx values('test01',87)
/*!*/;
# at 406
#180703 21:55:35 server id 1  end_log_pos 437 CRC32 0xdd7913a3  Xid = 392
COMMIT/*!*/;
# at 437
#180703 21:56:04 server id 1  end_log_pos 502 CRC32 0x0d09bd0b  Anonymous_GTID  last_committed=1    sequence_number=2
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 502
#180703 21:56:04 server id 1  end_log_pos 581 CRC32 0xe6040c79  Query   thread_id=46    exec_time=0 error_code=0
SET TIMESTAMP=1530626164/*!*/;
BEGIN
/*!*/;
# at 581
#180703 21:56:04 server id 1  end_log_pos 691 CRC32 0x2d99f699  Query   thread_id=46    exec_time=0 error_code=0
SET TIMESTAMP=1530626164/*!*/;
delete from yx where name='zhangsan'
/*!*/;
# at 691
#180703 21:56:04 server id 1  end_log_pos 722 CRC32 0x4a742173  Xid = 393
COMMIT/*!*/;
# at 722
#180703 21:56:11 server id 1  end_log_pos 787 CRC32 0x6d0b47d8  Anonymous_GTID  last_committed=2    sequence_number=3
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 787
#180703 21:56:11 server id 1  end_log_pos 866 CRC32 0x97e2deb7  Query   thread_id=46    exec_time=0 error_code=0
SET TIMESTAMP=1530626171/*!*/;
BEGIN
/*!*/;
# at 866
#180703 21:56:11 server id 1  end_log_pos 974 CRC32 0x9e24e8af  Query   thread_id=46    exec_time=0 error_code=0
SET TIMESTAMP=1530626171/*!*/;
insert into yx values('test02',99)
[root@promote data]# mysql -u root -p test < /opt/test.sql   #先進(jìn)行完全恢復(fù)
mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
+----------+--------+
4 rows in set (0.00 sec)
[root@promote data]# mysqlbinlog --no-defaults --stop-datetime='18-07-03 21:56:04' mysql-bin.000003 | mysql -u root -p   #結(jié)束節(jié)點(diǎn)
Enter password:
[root@promote data]# mysqlbinlog --no-defaults --start-datetime='18-07-03 21:56:11' mysql-bin.000003 | mysql -u root -p   #重新開(kāi)始節(jié)點(diǎn)
Enter password:
mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
| test01   |  87.00 |
| test02   |  99.00 |
+----------+--------+
6 rows in set (0.00 sec)

2、基于位置恢復(fù),其中581是錯(cuò)誤語(yǔ)句的節(jié)點(diǎn),866是第二句正確語(yǔ)句的節(jié)點(diǎn)

[root@promote data]# mysql -u root -p test < /opt/test.sql
mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
+----------+--------+
4 rows in set (0.01 sec)
[root@promote data]# mysqlbinlog --no-defaults --stop-position='581' mysql-bin.000003 | mysql -u root -p
Enter password:
[root@promote data]# mysqlbinlog --no-defaults --start-position='866' mysql-bin.000003 | mysql -u root -p
Enter password:
mysql> select * from yx;
+----------+--------+
| name     | score  |
+----------+--------+
| zhangsan | 100.00 |
| lisi     |  90.00 |
| wangwu   |  80.00 |
| zhaoliu  |  99.00 |
| test01   |  87.00 |
| test02   |  99.00 |
+----------+--------+
6 rows in set (0.00 sec)

您可能感興趣的文章:

  • MySQL數(shù)據(jù)庫(kù)備份與恢復(fù)方法
  • MySQL忘記密碼恢復(fù)密碼的實(shí)現(xiàn)方法
  • 用mysqldump備份和恢復(fù)指定表的方法
  • MySQL數(shù)據(jù)庫(kù)恢復(fù)(使用mysqlbinlog命令)
  • 詳解Mysql自動(dòng)備份與恢復(fù)的幾種方法(圖文教程)
  • mysql 誤刪除ibdata1之后的恢復(fù)方法
  • MYSQL使用.frm恢復(fù)數(shù)據(jù)表結(jié)構(gòu)的實(shí)現(xiàn)方法
  • Linux下實(shí)現(xiàn)MySQL數(shù)據(jù)備份和恢復(fù)的命令使用全攻略
  • MySQL單表ibd文件恢復(fù)方法詳解
  • 聲明:本網(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

    文檔

    Mysql實(shí)現(xiàn)增量恢復(fù)的方法詳解

    Mysql實(shí)現(xiàn)增量恢復(fù)的方法詳解:實(shí)驗(yàn)介紹 增量恢復(fù)一般適用的場(chǎng)景: 1、人為的sql語(yǔ)句破壞了數(shù)據(jù)庫(kù) 2、在進(jìn)行下一次完全備份之前發(fā)生系統(tǒng)故障導(dǎo)致數(shù)據(jù)庫(kù)數(shù)據(jù)丟失 3、在主從架構(gòu)中,主庫(kù)數(shù)據(jù)發(fā)生了故障 丟失完全備份之后更改的數(shù)據(jù)的恢復(fù)步驟 1、首先做一個(gè)完全備份,確保生成完全備份的sq
    推薦度:
    標(biāo)簽: 還原 恢復(fù)的 講解
    • 熱門焦點(diǎn)

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 亚洲 欧美 中文 日韩欧美 | 亚洲欧美视频一区二区三区 | 国产欧美在线播放 | 免费观看国产一区二区三区 | 欧美区一区二区三 | 国产日韩欧美综合在线 | 欧美另类激情 | 国产欧美另类 | 一级毛片免费下载 | 中文字幕在线播放第一页 | 色婷婷综合久久久久中文一区二区 | 91在线精品亚洲一区二区 | 日韩 国产 欧美 精品 在线 | 国产亚洲精品成人婷婷久久小说 | 亚洲一区二区成人 | 日韩欧美电影在线观看 | 免费观看a毛片一区二区不卡 | 精品视频在线观看视频免费视频 | 免费黄毛片 | 亚洲一区在线播放 | 国产精品伦视频观看免费 | 精品国产一区二区三区在线 | 国内精品久久久久久久97牛牛 | 久久国产精品电影 | 日韩 欧美 中文 | 国产高清视频 | 亚洲欧美精品伊人久久 | 国产精品成人va | 国产高清在线精品一区二区三区 | 综合伊人久久在一二三区 | 亚洲一区有码 | 在线观看日韩视频 | 亚洲欧美另类自拍 | 欧美资源在线观看 | 欧美 亚洲 一区 | 精品国产3p一区二区三区 | 精品伊人久久大线蕉色首页 | 国产资源一区 | 四虎福利视频 | 免费一区二区视频 | 看全色黄大色大片免费久久 |