1

I am trying to change the max_connections configuration for a mysql instance running on a Ubuntu 16.04 server. I have tried placing this configuration...

[mysqld]
max_connections = 400

...in the following files already: /etc/my.cnf, /etc/mysql/my.cnf, /etc/mysql/mysql.conf.d/mysqld.cnf, /etc/mysql/conf.d/mysql.cnf.

I also added the following lines to /etc/apparmor.d/usr.sbin.mysqld and restarted apparmor:

/etc/mysql/mysql.conf.d/* rl,
/etc/mysql/conf.d/* rl,

Nevertheless, every time I restart the mysql service, I am getting a value of 214 from the following query:

show global variables like "max_connections";

The mysql version is mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper.

What am I missing?

1
  • 1
    I changed mine in /etc/mysql/my.cnf and restarted mysql and it changed Commented Oct 11, 2017 at 15:51

1 Answer 1

2

In Ubuntu 16.04 the limits for the MySQL service are defined in the Systemd configuration file. To force MySQL read the value defined in your mysqld.cnf edit the service config:

sudo systemctl edit mysql.service

Add the following lines then save the file:

[Service]
LimitNOFILE=infinity

Restart the service:

sudo systemctl daemon-reload
sudo systemctl restart mysql.service

MySQL should use now the value defined in you config files.

2
  • I was looking for this and finally found after googling one day. Worked like charm on Ubuntu 16.04. Thanks!
    – Om Prakash
    Commented Sep 24, 2019 at 7:04
  • This saved me eventually Commented Jun 14, 2022 at 4:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .