資料庫篇 簡單的資料恢復流程

2021-10-03 15:38:34 字數 1417 閱讀 9185

建立模擬資料

create database test_bk;

use test_bk;

create table t1 (id int)

;insert into t1 values(1),(2),(3)

;commit;

select * from t1;

首先進行全備份
mysqldump -uroot -p123456 -a -e -r --triggers --set-gtid-purged=off --master-data=2 --single-transaction|

gzip

> backup/full_$(

date +%f)

.sql.gz

刪除資料
cd test_bk &&

rm -rf *

建立其他資料
create table t2 (id int)

;insert into t2 values(111),(222),(333)

;select * from t2;

解壓sql檔案,進行查詢 master_log_pos號
gunzip full_2018_07_10.sql
大概在行數的第 20~30行
show binlog events in

'mysql-bin.000004'

;change master to master_log_file=

'mysql-bin.000004', master_log_pos=2446;

mysql -uhailong -p123456 -e "show binlog events in 'mysql-bin.000004'"

|tail -100 |

grep -i 'drop'

mysql-bin.000004 259 query 1 2446 drop database test_bk

進行 mysqlbinlog匯出資料
mysqlbinlog --skip-gtids --start-position=2339 --stop-position=2446 -d backup_bk ../mysql-bin.000004 > /tmp/bk.sql
source /tmp/bk.sql;
query ok, 0 rows affected (0.01 sec)

query ok, 0 rows affected (0.00 sec)

query ok, 0 rows affected (0.00 sec)

# 恢復成功

資料庫簡單備份與恢復

在執行輸入cmd 在cmd下輸入exp windone wind orclwind file f data.dmp log f logimp.log owner windone 即可完成資料備份 windone是使用者名稱 wind是密碼 orclwind是資料庫名 owner windone 這個...

資料庫恢復

如果有備份,直接從備份恢復即可。否則,借助第三方工具log explorer log explorer 解壓縮密碼 www.heibai.net 序號產生器產生的是註冊碼,是兩個 用解壓縮密碼解開後,壓縮包裡也有乙個序號產生器的 開啟log explorer file attach log file...

資料庫恢復

3.中斷的事務 3.2 undo redo日誌恢復 4.檢查點技術 查詢和更新資料庫時,由於某些問題 故障 發生可能會導致資料庫被破壞或影響資料庫中資料的一致性。資料庫恢復技術將資料庫從錯誤狀態恢復到某個一致狀態,它是資料庫可靠性的保證。事務故障 內部原因 介質故障 物理原因 系統故障 其他原因 存...