Could not increase number of max_open_files to more than… (Solution)

A quick solution to the warning “Could not increase number of max_open_files to more than” when starting MySQL or MariaDB. For some background, read How MySQL Opens and Closes Tables. Here’s an excerpt: “The table_open_cache and max_connections system variables affect the maximum number of files the server keeps open. If you increase one or both of these values, you may run up against a limit imposed by your operating system on the per-process number of open file descriptors. Many operating systems permit you to increase the open-files limit, although the method varies widely from system to system. Consult your operating system documentation to determine whether it is possible to increase the limit and how to do so.”

Also, read MySQL’s open_files_limit documentation, which states: “The number of files that the operating system permits mysqld to open. The value of this variable at runtime is the real value permitted by the system and might be different from the value you specify at server startup. The value is 0 on systems where MySQL cannot change the number of open files. …The effective open_files_limit value is based on the value specified at system startup (if any) and the values of max_connections and table_open_cache. The server attempts to obtain the number of file descriptors using the maximum of those three values. If that many descriptors cannot be obtained, the server attempts to obtain as many as the system will permit.”

Too many open files

So, for example, if MySQL starts with the following warning:

Could not increase number of max_open_files to more than 65536

…this means the limit is being hit somewhere. Let’s resolve that by editing any configured limits. Have a look at the following files:


Look within those files for the following config lines:


Change these lines to your new limit. For example:


Please don’t use the infinity as a value; it defaults to 65536. (as reported here) So if you see the value infinity, replace it with your required limit.

Update: The related MySQL or MariaDB files may be in other locations on non-RHEL systems. For example, on Ubuntu create a new file /etc/systemd/system/mysql.service.d/override.conf then add the new limit there:


Once you’ve done this, you should now reload the system daemon and restart the MySQL service:

systemctl daemon-reload
systemctl restart mysql

To check the new limit via the MySQL command line. You can use the following query:

SHOW VARIABLES LIKE 'open_files_limit';

Make sure your new limit is set:

MariaDB [(none)]> SHOW VARIABLES LIKE 'open_files_limit';
| Variable_name    | Value  |
| open_files_limit | 100000 |

Published: November 16th, 2019
Updated: November 1st, 2021

Tags: , , , , , ,