MySQL couldn't find log file

This error will pop up when binary logging is enabled, and someone thought it was a good idea to remove binary logs from the filesystem:

/usr/sbin/mysqld: File './mysql_bin.000025' not found (Errcode: 2)
[ERROR] Failed to open log (file './9531_mysql_bin.000025', errno 2)
[ERROR] Could not open log file
[ERROR] Can't init tc log
[ERROR] Aborting

InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 0 2423986213
[Note] /usr/sbin/mysqld: Shutdown complete

Basically, MySQL is looking in the mysql-bin.index file and it cannot find the log files that are listed within the index. This will keep MySQL from starting, but the fix is quick and easy. You have two options:

Edit the index file
You can edit the mysql-bin.index file in a text editor of your choice and remove the references to any logs which don't exist on the filesystem any longer. Once you're done, save the index file and start MySQL.

Take away the index file
Move or delete the index file and start MySQL. This will cause MySQL to reset its binary log numbering scheme, so if this is important to you, you may want to choose the previous option.

So how do you prevent this from happening? Use the PURGE MASTER LOGS statement and allow MySQL to delete its logs on its own terms. If you're concerned about log files piling up, adjust the expire_logs_days variable in your /etc/my.cnf.

Further reading:
12.6.1.1. PURGE MASTER LOGS Syntax
5.2.3 System Variables

Printed from: http://rackerhacker.com/2007/08/23/mysql-couldnt-find-log-file/ .
© Major Hayden 2012.

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden

    Flattr this