Tuesday, November 20, 2012

ERROR 1018 (HY000): Can't read dir of '.' (errno: 24)

We encountered an error in MySQl below:

ERROR 1018 (HY000): Can't read dir of '.' (errno: 24)

Upon searching for some solutions at google we found out that the error means 'Too many open files'. Everything you do in linux is a file (or rather a file descriptor). Every mysql connection, every apache connection etc.

To see how many files a user has open try this

sudo lsof -u mysql

edit the file in /etc/security/limits.conf and add these two mysql lines in at the bottom

#@student        -       maxlogins       4
mysql   soft    nofile  4096
mysql   hard    nofile  8192
# End of file

There is some debate as to whether you need to reboot for this to take effect (i say debate, i rebooted, and didnt google for it as i was in a rush ymmv).
Once this is set you need to make some changes in the mysql file as well. Assuming yours lives in /etc/mysql/my.cnf - edit or add these values

open-files-limit = 2048
table_cache            = 512

The table_cache should be researched (start here: http://dev.mysql.com/doc/refman/5.0/en/table-cache.html) and changes monitored. The default value is 64, so 512 should be a safe bet to begin with.


Anonymous said...

Thanks for posting this - it 100% fixed my problem.

mike3 said...

Anytime David! Always glad to help!

Sqiar BI said...

Thanks a lot for sharing this with all folks you really recognise what you are talking about! In this complex environment business need to present there company data in meaningful way.Sqiar (http://www.sqiar.com/consultancy/tableau/) which is in UK,provide services like Tableau and Data Warehousing etc .In these services sqiar experts convert company data into meaningful way.

Salomão Rodrigues said...

Thanks, this has helped alot!

Sitakanta said...

Thanks for the post... I got Instant fix for the error... :)

Saiba Meister said...

Thank you so much!
Our websites worked until this morning, seems that somebody hacked the server.
After cleaning the hack-script, the databases did not show up anymore.

Your Info was the solution to this problem.

It's great to have people like you, sharing your know-how with us.
Saved my day.

Mr Budgie said...

OMG, THankS So MuCh, lifeSever!!