2

We've had some problems with one of our more elderly MySQL servers (version 5.045). The database is back up and running OK but there were over twenty thousand binary log files in the mysql folder.

I logged into MySQL and issued the following command after checking that data replication was all working OK...

purge binary logs to 'mysql-bin.024717';

The command completed without error and the resulting mysql-bin.index looks like this...

./mysql-bin.024717
./mysql-bin.024718
./mysql-bin.024719
./mysql-bin.024720
./mysql-bin.024721
./mysql-bin.024722
./mysql-bin.024723
./mysql-bin.024724

When I left mysql a lot of files had gone, but now there are still over a thousand binary log files left, all from before mysql-bin.024717 and most of them only containing 117 bytes.

Given that they are no longer referenced in the mysql-bin.index file is it OK for me to just go ahead and remove them with rm at the OS level or do I need to do something else to clean them up?

Thanks in Advance

asked Apr 29, 2016 at 10:33

2 Answers 2

2

You can also try purge binary logs before '2016-04-29 08:00:00'. I sometimes find one works when the other doesn't for some reason.

Failing that just delete them with rm like you said. It's not technically correct, but it shouldn't be a problem (I did this frequently in the past before I learned about the PURGE commands, and never had any problems).

Of course you also want to make sure you have expire_logs_days set as well to keep them down in future.

I also just saw this note:

Prior to MySQL 5.1.24, PURGE BINARY LOGS TO and PURGE BINARY LOGS BEFORE did not behave in the same way (and neither one behaved correctly) when binary log files listed in the .index file had been removed

for some reason I don't have access to the 5.0 page to check what that says.

answered Apr 29, 2016 at 12:27
0

(Follow-on to @IGGt)

"Prior to MySQL 5.0.60, PURGE BINARY LOGS TO and PURGE BINARY LOGS BEFORE did not behave in the same way (and neither one behaved correctly) when binary log files listed in the .index file had been removed from the system by some other means (such as using rm on Linux). Beginning with MySQL 5.0.60, both variants of the statement fail with an error in such cases. (Bug #18199, Bug #18453) To handle such errors, edit the .index file (which is a simple text file) manually to ensure that it lists only the binary log files that are actually present, then run again the PURGE BINARY LOGS statement that failed." -- http://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html

PURGE BINARY LOGS was added in 4.1 or 5.0, I don't remember which.

answered May 1, 2016 at 23:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.