No more hands, no more. Recover data with Mysqlbinlog

Source: Internet
Author: User

Today, the local deployment of a new project, the result of accidentally put another library of the table all deleted, then that heart, with some hard disk recovery tools have not recovered, had to think of another way, fortunately recorded the Binlog, finally the data are restored. After really want to see clearly again deleted, fortunately is the local article library, not the library on the server, or really trouble, but also because it is the library on their own computer, never back up, so it is really troublesome to recover. Keep a record here.

First make sure your MySQL has no bin log enabled, just look at the Log-bin=mysql-bin in Mysql.ini (MY.CNF), you can customize a directory and prefix name, such as/data/log/mylog.

Then in the database files stored in the data directory can see mysql-bin.00000x such a file, which is binary log, we can export to TXT format, which is actually the database of various operational SQL statements.

Export TXT file:

E:\wamp\bin\mysql\mysql5.6.12\bin>mysqlbinlog--database=testdatabase E:\wamp\bin\mysql\mysql5.6.12\data\ mysql-bin.000312 > C:\\test1.txt

This is the export under Windows, and Linux is similar.

*--database= database name

* restore

from the oldest log

*linux can be very convenient mysql-bin.000*

* can add parameter start time and end time, which is the time you execute that SQL statement

*--start-datetime=" 2014-12-04 11:25:56 "--stop-datetime=" 2014-12-04 13:23:50 " 


Recover data:

E:\wamp\bin\mysql\mysql5.6.12\bin>mysqlbinlog--database=yundongchao E:\wamp\bin\mysql\mysql5.6.12\data\ mysql-bin.000179 | Mysql-u root-p


------------------------------------------------

My Independent blog: Accommodating Kid- http://www.zyblog.net/

This article link: http://www.zyblog.net/post-178.html

fitness boom: http://www.jianshenchao.com

Welcome reprint, Reproduced Please indicate the source of this article.

No more hands, no more. Recover data with Mysqlbinlog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.