Skip to main content
Enterprise applications

File descriptors

Contributors jfsinmsp

To run, the MySQL server needs file descriptors, and the default values are not sufficient.

It uses them to open new connections, store tables in the cache, create temporary tables to resolve complicated queries, and access persistent ones. If mysqld is not able to open new files when needed, it can stop functioning correctly. A common symptom of this issue is error 24, “Too many open files.” The number of file descriptors mysqld can open simultaneously is defined by the open_files_limit option set in the configuration file (/etc/my.cnf). But open_files_limit also depends on the limits of the operating system. This dependency makes setting the variable more complicated.

MySQL cannot set its open_files_limit option higher than what is specified under ulimit 'open files'. Therefore, you need to explicitly set these limits at the operating system level to allow MySQL to open files as needed. There are two ways to check the file limit in Linux:

  • The ulimit command quickly gives you a detailed description of the parameters being allowed or locked. The changes made by running this command are not permanent and will erase after a system reboot.

  • Changes to the /etc/security/limit.conf file are permanent and are not affected by a system reboot.

Make sure to change both the hard and soft limits for user mysql. The following excerpts are from the configuration:

mysql hard nofile 65535
mysql soft nofile 65353

In parallel, update the same configuration in my.cnf to fully use the open file limits.