database

How do I clean up MySQL bin logs?

If you are NOT replicating, you can disable bin logging by changing your my.ini or my.cnf file.

# vi /etc/my.cnf
Find a line that reads “log_bin” and remove or comment it as follows:

#log_bin = /var/log/mysql/mysql-bin.log

You also need to remove or comment following lines:

#expire_logs_days = 10
#max_binlog_size = 100M

Close and save the file and then restart mysql server:

# service mysql restart

If you ARE replicating, then you need to periodically RESET MASTER or PURGE MASTER LOGS to clear out the old logs as those files are necessary for the proper operation of replication. Use following command to purge master logs:

$ mysql -u root -p ‘MyPassword’ -e “PURGE BINARY LOGS TO ‘mysql-bin.03’;”

OR

$ mysql -u root -p ‘MyPassword’ -e “PURGE BINARY LOGS BEFORE ‘2008-12-15 10:06:06’;”

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top