Are you seeing the “Could not increase number of max_open_files to more than X” warning when restarting MySQL in WHM? I was seeing this warning even after changing open_file_limits in my.cnf, but I figured out the solution.

Are you seeing the “Could not increase number of max_open_files to more than X” warning when restarting MySQL in WHM? I was seeing this warning even after changing open_file_limits in my.cnf.

The open_file_limits seemed to be stuck despite any changes I made, but I figured out the solution. Hopefully, this mini tutorial will save you a lot of time. Note: I’m using a VPS with CentOS and connecting with PuTTY.

Step 1

Assuming you are root in the terminal, type:

nano /etc/systemd/system/mariadb.service.d/override.conf

or (Depending on which you are using – I’m using MariaDB)

nano /etc/systemd/system/mysqld.service.d/override.conf

Step 2

Now we can edit the file, which should be blank at the moment. Type:

[Service]
LimitNOFILE=X

(X being the value you want)

Step 3, 4, & 5

Type:

Ctrl+X
Y
Enter

Step 6 & 7

Now to check our work. Type:

cat /etc/systemd/system/mariadb.service.d/override.conf

or (Depending on which you are using – I’m using MariaDB)

cat /etc/systemd/system/mysqld.service.d/override.conf

This will display what’s in the file. If incorrect, simply go back and edit the file again. If it’s correct, type:

systemctl daemon-reload

Step 8

Time to restart MySQL. I prefer to restart from WHM to see there are no more warnings. If you want a quick terminal MySQL restart, type: