Mysql之日誌恢複

來源:互聯網
上載者:User

標籤:mysql   dml   event   tput   技術分享   com   img   decode   如何   

對於Mysql,每一步操作都會有相應記錄,如insert,update,delete ,drop ,alter等相關DDL或DML操作。有時難免會出錯,但在出錯時如何恢複以複原資料。

例如,現在有這些資料:

但被我truncate了。需要緊急恢複。

首先,確保開啟了binLog輸出

然後,找到當前記錄檔,使用show master status 如:

之後,拷出記錄檔,

可以使用:show binlog events in ‘binLog.000001‘,查看相半區間,也可以使用BinLog來尋找

 

之後,flush logs[可產生新的記錄檔],reset master【刪除所有的記錄檔】

然後,使用mysqlbinlog --vv --base64-output=DECODE-ROWS,找出要恢複的操作區間:

最後,使用mysqlbinlog 恢複,如:mysqlbinlog  --start-position=10468 --stop-position=10680  /tmp/binlog01 | mysql -uroot -p123456.

結束。

也可參見:http://www.cnblogs.com/martinzhang/p/3454358.html。

Mysql之日誌恢複

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.