MySQL Bin-log Log Cleanup method

Source: Internet
Author: User
Tags log log

MySQL Bin-log effect 1. Data recovery: If your database is out of order and you have a previous backup, you can look at the log file to find out which command caused your database to go wrong and try to recover the loss. 2. Synchronize data between master and slave servers: all operations on the primary server are in the log, and the server can be based on the log to ensure two synchronizations. 3. At what time will the expiration log be deleted? The log flush is automatically deleted each time it is logged, and the explanation in the manual is:
    1. Restart MySQL
    2. Bin-log file size reaches the parameter max_binlog_size limit;
    3. Manually perform cleanup commands

Automatic Cleanup Method 1: (Modify the configuration file and set parameters within MySQL can not restart the service) Vim my.cnfexpire_logs_days = 7//indicates log retention 7 days, more than 7 days set to expired # Mysql-u root-p > Show bin ary logs; > Show variables like '%log% '; > Set Global expire_logs_days = 7; Manual Cleanup Method 2: (recommended) If there is no master-slave replication, you can reset the database log by using the following command to clear the previous log file: Reset Master But if there is a replication relationship, the Bin-log log should be cleaned by the name of PURGE, with the following syntax: # mysql-u Roo T-p> purge master logs to ' mysql-bin.010 '; Clear mysql-bin.010 log > Purge master logs before ' 2016-02-28 13:00:00 '; Clear 2016-02-28 13:00:00 logs > Purge master logs before date_sub (now (), Interval 3 day); Clear the Bin log 3 days ago Note, do not easily manually remove Binlog, will cause binlog.index and the real binlog mismatch, resulting in expire_logs_day failure

MySQL Bin-log Log Cleanup method

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.