Original Log rollback for MySQL under CentOS

Source: Internet
Author: User

First, Environment:

A) centos-6.5-x64-bit operating system.

b) Install MySQL. Command: Yum install mysql*

Second, Configuration

A) Configure the/etc/my.cnf file

[Mysqld]

Log-bin=bin-log//Configure turn on log function

Third, Implement

    1. Check the/var/lib directory for log files that do not resemble bin-log.000001.
    2. Log in to MySQL execution: Flush logs;//Refresh the log, and then look at the log file, if you do not perform the flush logs and restart MySQL, then all of the MySQL operation will be recorded in the log file after the refresh. Command: Mysqlbinlog–no-defaults bin-log.000001 | More
    3. Log in to MySQL, create tables, and insert a series of test data as objects to be recovered. Execute the flush logs again to generate the bin-log.000002 log file. The data and tables are then deleted.
    4. Now restore the data. Open another terminal and execute the command:

Mysqlbinlog–no-defaults bin-log.000001 | Mysql–u root–p

Enter the root password. Return to view, both the table and the data have been restored.

Four, Mysqlbinlog syntax: Time-based (date) and Location (position) the recovery

1. Positioning:--start-position start point

--stop-position End Point

--start-date Start time

--stop-date End Time

2. Example:

Mysqlbinlog–no-defaults–start-position POS Value –stop-position pos value bin-log.000001 | Mysql–u root–p

Note: The positioning keywords can be paired or used alone, to achieve a slight phenomenon.

Original Log rollback for MySQL under CentOS

Related Article

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.