MySQL: Errcode: 24 when using LOCK TABLES

While running into MySQL’s open files limit will manifest itself into various error messages, this is the standard one that you’ll receive during a mysqldump:

mysqldump: Got error: 29: File './databasename/tablename.MYD' not found 
(Errcode: 24) when using LOCK TABLES

The best way to get to the bottom of the error is to find out what it means:

$ perror 24
OS error code  24:  Too many open files

There’s two ways to fix the problem. First, if you find that you only hit the limit during mysqldumps and never during normal database operation, just add --single-transaction to your mysqldump command line options. This will cause mysql to keep only one table open at a time.

However, if this happens while backups aren’t running, you may want to increase the open_files_limit in your MySQL configuration file. By default, the variable is set to 1,024 open files.

For further reading:
5.2.3. System Variables
7.13. mysqldump – A Database Backup Program

Tagged

13 thoughts on “MySQL: Errcode: 24 when using LOCK TABLES

  1. Pramod says:

    Thanks it works fine with single transaction

  2. Axel says:

    Thanks, this solution save my day.

  3. RealMcCoy says:

    Thanks mate! This really helped. :-)

  4. shiloh says:

    thank you so much. it really helps

  5. patrick says:

    Thanks, worked out just fine.

  6. Jonathan says:

    thank you – JEG

  7. Steffen says:

    That rocks, thanks!

  8. Alex says:

    Thank you so much man, the –single transaction command did the trick. Perfect. Greetings, Alex.

  9. [...] funktioniert der Dump dann auch. Siehe dazu auch http://rackerhacker.com/2007/08/19/mysql-errcode-24-when-using-lock-tables/ Posted in Tipps und Tricks, linux | No Comments [...]

  10. platzhersh says:

    Thx dude, it worked just fine

    cheers

  11. Mark Nett says:

    Any undesired consequences after modifying this variable — open-files-limit = 1024.

    Can we get complete backup of the Databases?

  12. Mike Boudet says:

    Great help. This worked perfectly. Thanks!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>