Can not increase max_open_files for Mysql max-connections in Ubuntu 15

I am running this version of Mysql

Ver 14.14 Distrib 5.6.24, for debian-linux-gnu (x86_64)

On this version of Ubuntu

Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:    15.04
Codename:   vivid

This is the config I set for Mysql:

key_buffer_size     = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
tmp_table_size = 32M
max_heap_table_size = 32M
myisam-recover         = BACKUP
query_cache_limit   = 32M
query_cache_size        = 32M

These are the warnings I keep getting when starting MYSQL:

2015-06-17 17:28:53 26720 [Warning] Buffered warning: Could not increase number 
of max_open_files to more than 1024 (request: 4510)

2015-06-17 17:28:53 26720 [Warning] Buffered warning: Changed limits: max_connections: 
214 (requested 500)

2015-06-17 17:28:53 26720 [Warning] Buffered warning: Changed limits: table_open_cache: 
400 (requested 2000)

I already tried these steps:

1) Adding this to /etc/security/limits.conf

mysql           soft    nofile          65535
mysql           hard    no file          65535

2) Adding this to /etc/pam.d/common-auth and /etc/pam.d/commom-session

session required

3) Add this to /etc/mysql/mysql.conf.d/mysqld.cnf

open-files-limit=4510 or open_files_limit=4510

None of these have worked and I am still not able to raise the mysql max connections to 500.

I’d really appreciate some help at this point.

Thanks a lot in advance.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Ubuntu has moved from Upstart to Systemd in version 15.04 and no longer respects the limits in /etc/security/limits.conf for system services. These limits now apply only to user sessions.

The limits for the MySQL service are defined in the Systemd configuration file, which you should copy from its default location into /etc/systemd and then edit the copy.

sudo cp /lib/systemd/system/mysql.service /etc/systemd/system/
sudo vim /etc/systemd/system/mysql.service # or your editor of choice

Add the following lines to the bottom of the file:


You could also set a numeric limit, eg LimitNOFILE=4510.

Now reload the Systemd configuration with:

sudo systemctl daemon-reload

Restart MySQL and it should now obey the max_connections directive.

I also had problems stopping MySQL cleanly after upgrading to 15.04. If this affects you (you’ll know because it will take 300 seconds to time out when you do service mysql stop or service mysql restart) then adding the following line to the same /etc/systemd/system/mysql.service file fixed it for me:

ExecStop=/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown

This latter problem seems to have been fixed by 16.04 and this line is no longer required, so before you do a distribution upgrade you’ll want to stop MySQL and remove the ExecStop line from the config file.

Method 2

As of MySQL 5.7.7, this is what the documentation recommends for Red Hat Enterprise Linux 7, Oracle Linux 7, CentOS 7, SUSE Linux Enterprise Server 12, Fedora 24 and 25:

On Ubuntu 16.04 the service is called mysql, not mysqld, so this is what I did:

sudo mkdir /etc/systemd/system/mysql.service.d
sudo vi /etc/systemd/system/mysql.service.d/override.conf

Added this in the new file override.conf:


Then restarted the service:

sudo systemctl daemon-reload
sudo systemctl restart mysql

Method 3

I suggest you don’t copy the existing mysql.service file as suggested, just create a file with only the changes you care about. So do:

mkdir /lib/systemd/system/mysql.service.d
vim /etc/systemd/system/mysql.service.d/limits.conf

And the contents of limits.conf is simply:


or whatever limits you prefer.

Method 4

With systemd the file override.conf does not need to be searched for or possibly created. Just use the following command:

sudo systemctl edit mysql

If the file override.conf exists, it is read in, otherwise it can be created now.

The rest, as Frederik wrote: Enter LimitNOFILE and restart the services.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x