binlog2sql數據恢復
阿新 • • 發佈:2019-02-08
語句 mysql- 效果 哪裏 row 建立 執行 優劣 pip
牛叉的工具有好幾個,包括MyFlash、binlog2Sql、mysqlbinlog_flashback,還有一些收費的等等,各有優劣,具體使用可自行百度
1、安裝binlog2sql
shell> git clone https://gitee.com/qweff/binlog2sql && cd binlog2sql shell> pip install -r requirements.txt
git安裝方法:https://www.cnblogs.com/cjh-notes/p/10354532.html
pip在系統7以上的都是自帶的,6應該也有
2、設置MySql Server參數
配置文件默認路徑一般是:/etc/my.cnf
或 find -name / my.cnf 看看在哪裏
[mysqld] server_id = 1 log_bin = /var/log/mysql/mysql-bin.log max_binlog_size = 1G binlog_format = row binlog_row_image = full
3、測試恢復
這個官方已經寫得很詳細了,相當簡單,https://github.com/danfengcao/binlog2sql
需要註意的一點就是,當需要回滾的是DROP操作的時候,執行解析時會發現出來的效果不是我們想要的
這是因為表刪除後information_schema對應的元數據沒有了,所以CRUD的語句解析不出來,我們只需要把表(包括表結構)重新建立就可以了。
附上常用命令:
//查看目前的 show master status; //查看所有 show master logs;
官方項目GIT:https://github.com/danfengcao/binlog2sql
轉載請註明博客出處:http://www.cnblogs.com/cjh-notes/
binlog2sql數據恢復