How to check and set max_connections in MySQL

TheCompWiz

Well-known member
Registered
Joined
Apr 20, 2016
Messages
130
Points
18
I read that if a website has more than 150 connections to your Mysql then it could down and you need to restart your mysql server. Is that true? and how to check and set max_connections in MySQL?
 

FerdieQO

Well-known member
Joined
Jul 15, 2016
Messages
213
Points
28
I don't know what max_connections in Mysql use for, but if you want to check it using this command

Code:
SHOW VARIABLES LIKE "max_connections";
on my hosting, the result is

Code:
mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+
1 row in set (0.00 sec)
You can change max_connections while MySQL is running via SET:

Code:
SET GLOBAL max_connections = 10000;
After changed, I have the result as following


Code:
mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name   | Value   |
+-----------------+-------+
| max_connections | 10000  |
+-----------------+-------+
1 row in set (0.00 sec)

Hope that helps!
 

Luxin Host

Well-known member
Registered
Joined
Jun 26, 2016
Messages
543
Points
43
if you are using cpanel you can easily dis connect from all of those connections, that should solve your issue and stop the website from going down.
 

FerdieQO

Well-known member
Joined
Jul 15, 2016
Messages
213
Points
28
You would want to login to your cpanel.
1.) find either "FTP season control" or find "FTP connections" (this would be located under the files section)
2.) From here you can see all the connections. use this page to disconnect the connections which are unnecessary to get rid of the 421 error.
Now you are good to connect again. BTW a reply to OP's post, I have no known a time when 421 took down a website.

I will add two screen shots below demonstrating but as there are no current connections to that FTP you will not see any connections in the screen shot.
Why the OP is asking about max_connections in MySQL but you are talking to FTP connections and 421 error, there is a relation between them?


You could do it programatically by running the following command in mysql propmt

mysql> SET GLOBAL max_connections = 5000;
This already said above.
 
Newer Threads
Replies
7
Views
5,083
Replies
5
Views
3,085
Replies
2
Views
1,990

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top