MySQL Error: "Could not increase number of max_open_files" - Explained
- max_open_files: This refers to a setting that controls the maximum number of files a process can have open at once. In this case, it's specifically for the MySQL or MariaDB server process.
- 4096: This is the current limit on the number of open files. On some systems, the default is set to a low value like 1024 or 4096.
- request: 4214: This indicates that MySQL or MariaDB tried to increase the limit to 4214 files, but failed.
There are two main reasons why this error might occur:
- System-wide Limit: The operating system itself might have a hard limit set on the number of open files allowed for any process. This limit could be lower than 4214, preventing MySQL or MariaDB from raising its own limit.
- Permissions: The user running MySQL or MariaDB might not have permission to change the process's resource limits.
# This command shows the current system-wide limit
ulimit -n
Increase System-wide Open File Limit (if necessary):
- Edit the system configuration file
/etc/security/limits.conf
(requires root access). - Add a line like this for the user running MySQL/MariaDB (often
mysql
):
mysql soft nofile <new_limit>
mysql hard nofile <new_limit>
- Replace
<new_limit>
with a value higher than 4214 (choose wisely based on server needs). - Save the file and restart the system for changes to take effect.
Alternatively, Increase Limit for MySQL/MariaDB process (if allowed):
- Edit the systemd service file for MySQL/MariaDB (e.g.,
/etc/systemd/system/mysql.service
). - Look for a section with options like
LimitNOFILE
orLimitMEMLOCK
. - Add or modify the line to specify the desired limit:
LimitNOFILE=<new_limit>
- Save the file and reload systemd configurations:
sudo systemctl daemon-reload
- Restart the MySQL/MariaDB service:
sudo systemctl restart mysql
Important Note:
- Increasing system-wide open file limits can impact other processes. Choose a new limit carefully based on your server's resource availability.
- It's recommended to consult your Linux distribution's documentation for specific instructions on modifying these configuration files.
mysql linux mariadb