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
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
In the MySQL configuration file, locate the
max_connectionsparameter. It’s usually found under the
[mysqld]section. If the
max_connectionsentry doesn’t exist, you can add it. By default, the value is often set to 150.
max_connectionsvalue 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 press
Ctrl + X,
Enterto 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.