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