To increase the maximum allowed MySQL connections on your Ubuntu server, you need to adjust the max_connections
setting in the MySQL configuration file. Here’s how you can do it:
-
Open a terminal on your Ubuntu server.
-
Edit the MySQL configuration file using a text editor. For example, you can use the following command to edit it with
nano
:sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
-
In the MySQL configuration file, locate the
max_connections
parameter. It’s usually found under the[mysqld]
section. If themax_connections
entry doesn’t exist, you can add it. By default, the value is often set to 150. -
Modify the
max_connections
value to your desired number. For example, if you want to increase it to 500, modify the line to:max_connections = 500
-
Save the changes and exit the text editor (in
nano
, you can pressCtrl + X
,Y
, thenEnter
to save and exit). -
Restart the MySQL service to apply the changes:
sudo service mysql restart
After restarting MySQL, the max_connections
setting will be updated, allowing more concurrent connections to your MySQL server.
Remember that increasing the maximum number of connections also increases the resource consumption on your server, so ensure that your system has enough resources (memory, CPU) to handle the increased load. Additionally, keep in mind that the maximum number of connections is also limited by the server’s hardware capabilities and MySQL’s configuration limits.