Processing MySQL binary log file mysql-bin

Source: Internet
Author: User

MySQL runs for a long time there will be a lot of mysql-bin.xxxx files, each is quite large.

This is the binary file of MySQL. It records all MySQL database operations, such as all your SQL statements.

This file is useful when the database crashes or data is lost.

Master-slave synchronization can also ensure data consistency between the master and slave databases based on this log.

But it cannot grow at all. One day it will fill up the disk, so it should be processed in a timely manner.

The processing method is as follows:

Single-Host:

Turn off the binary log directly. Find log-bin in my. ini or my. CNF and comment it out.

If you still want to retain binary logs for a period of time, configure regular cleaning,

Or configure expire_logs_days in my file

For example:

Expire_logs_days = 10


When a master-slave server is available:

This requires manual deletion, and check which log is being operated by the slave server, or delete the log of the unsynchronized data.

The method is as follows:

1. Run show slave status on the slave server to check which log is being read from the slave server .;

2. Run show on the master server.
Master logs to view the current log list;

3. Delete all logs before the logs being read from the server

 
Purge master logs to 'Operation log name ';
Purge master logs before 'time ';

 
For example:

 
Purge master logs to 'mysql-binlimit 99 ';
Purge master logs before '2017-12-01 21:00:00 ';

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.