How to generate mysql-bin.000001 file and its processing method

Source: Internet
Author: User
Mysql-bin.000001 files are generated and processing methods mysql-bin.000001, mysql-bin.000002 and other files are database operation logs, such as UPDATE a table,

Mysql-bin.000001 files are generated and processing methods mysql-bin.000001, mysql-bin.000002 and other files are database operation logs, such as UPDATE a table,

How to generate mysql-bin.000001 file and its processing method
Files such as mysql-bin.000001, mysql-bin.000002 are database operation logs, such as updating a table, or deleting some data, even if the statement does not match the data, the command is stored in the log file, the execution time of each statement is also recorded.

There are two main purposes to do this:
1. Data Recovery
If there is a problem with your database, and you have had a backup before, you can check the log file to find out which command causes a problem with your database and find a way to recover the loss.

2: synchronize data between master and slave servers
All operations on the master server are recorded in the log. The slave server can follow the log to ensure two synchronization.

There are two solutions:
1: There is only one mysql server. You can simply comment out this option.
Vi/etc/my. cnf comment out the log-bin line and restart the mysql service.

# Replication Master Server (default)

# Binary logging is required for replication

Log-bin = mysql-bin

2: If your environment is a master-slave server, you need to perform the following operations.
A: On each SLAVE server, use show slave status to check which log it is reading.
B: Use SHOW MASTER LOGS to obtain a series of LOGS on the MASTER server.
C: Identify the earliest log among all slave servers. This is the target log. If all slave servers are updated, it is the last log in the list.
D: clear all the logs, but not the target logs, because the slave server needs to synchronize with it.

The log cleanup method is as follows:

Purge master logs to 'mysql-bin.010 ';

Purge master logs before '2017-12-19 21:00:00 ';

If you are sure that the slave server has been synchronized, just like the MASTER server, you can directly RESET the MASTER to delete these files.

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.