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:
- Restart MySQL
- Bin-log file size reaches the parameter max_binlog_size limit;
- 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