+3 votes
in Databases by (60.1k points)
How can I check the maximum number of database connections allowed by MySQL on my VPS and how to change the current value?

1 Answer

+1 vote
by (355k points)
selected by
 
Best answer

1. To check the current value of max_connections, log into the MySQL server and type SHOW VARIABLES LIKE '%connections%'; on the MySQL command line.

MariaDB [(none)]> SHOW VARIABLES LIKE '%connections%';

+-----------------------+-------+

| Variable_name         | Value |

+-----------------------+-------+

| extra_max_connections | 1     |

| max_connections       | 151   |

| max_user_connections  | 0     |

+-----------------------+-------+

2. To change the current value of max_connections, type SET GLOBAL max_connections = xxx; on the MySQL command line, where xxx=your desired value.

MariaDB [(none)]> SET GLOBAL max_connections = 250;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SHOW VARIABLES LIKE '%connections%';

+-----------------------+-------+

| Variable_name         | Value |

+-----------------------+-------+

| extra_max_connections | 1     |

| max_connections       | 250   |

| max_user_connections  | 0     |

+-----------------------+-------+

Note: If you restart your VPS or MySQL server, you will lose these values.


...