Master da Web
Back to Blog

Increasing Max MySQL Connections

LucasFebruary 18, 20121 min readUpdated on November 4, 2023

To increase the maximum number of connections that MySQL allows, you must edit the ‘/etc/my.cnf’ file. Log in to the server as ‘root’, and type the following command:

vi /etc/my.cnf

There should be a part of the file that looks like the example below:

[mysqld]
safe-show-database
innodb_data_file_path=ibdata1:10M:autoextend
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

 

Add the following variable below ‘[mysqld]’:

max_connections=500

 

NOTE: The value 500 is the maximum number of connections to be changed, choose a value according to your needs.

 

It should look something like this:

[mysqld]
safe-show-database
innodb_data_file_path=ibdata1:10M:autoextend
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
max_connections=500

 

Save the changes and restart the database:

/etc/init.d/mysqld restart

 

You’ll see:

Stopping mysql: [ OK ]
Starting mysql: [ OK ]

 

 

Tags#Connections#Max#mysql
Share

Need Hosting or Servers?

Discover our VPS, dedicated servers and professional hosting solutions

Related Articles

View all articles