This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16757|Reply: 2

[Source] The MySQL database displays information about the number of connections and concurrency

[Copy link]
Posted on 5/8/2018 11:16:45 AM | | | |
First of all, attach the tools used in this article, because I am a remote server, so I can't install some database query tools, so I can only use the general query software I wrote, as follows:

.NET/C# Universal Database Query Tool Helper [with source code]
http://www.itsvse.com/thread-4201-1-1.html
(Source: Architect_Programmer)


1.mysql> show status like 'Threads%';

[{"Variable_name":"Threads_cached","Value":"0"},{"Variable_name":"Threads_connected","Value":"101"},{"Variable_name":"Threads_created","Value":"119"},{"Variable_name" :"Threads_running","Value":"2"}]




Threads_connected #这个数值指的是打开的连接数
Threads_running #这个数值指的是激活的连接数, this value is generally much lower than the connected value
Threads_connected The result is the same as show processlist, indicating the current number of connections. To be precise, Threads_running represents the current number of concurrency


2.mysql> show variables like '%max_connections%';




[{"Variable_name":"max_connections","Value":"151"}]


This is the maximum number of connections currently set by the query database

You can set the maximum number of connections to the database in /etc/my.cnf
[mysqld]
max_connections = 1000
max_connections parameters can be used to control the maximum number of connections to the database:


3.mysql> show variables like '%connect%';



[{"Variable_name":"character_set_connection","Value":"utf8"},{"Variable_name":"collation_connection","Value":"utf8_general_ci"},{"Variable_name":"connect_timeout"," Value":"10"},{"Variable_name":"disconnect_on_expired_password","Value":"ON"},{"Variable_name":"init_connect","Value":""},{"Variable_name":"max_connect_errors","Value" :"100"},{"Variable_name":"max_connections","Value":"151"},{"Variable_name":"max_user_connections","Value":"0"},{"Variable_name":"performance_schema_session_connect_ attrs_size","Value":"512"}]


Many developers will encounter the abnormal situation of "MySQL: ERROR 1040: Too many connections", one of the reasons for this situation is that the number of visits is too high, and the MySQL server cannot resist it, so it is necessary to consider increasing the pressure of distributed reads from the server; Another reason is that the max_connections value in the MySQL configuration file is too small.




Previous:Windows view the log of connecting via Remote Desktop
Next:Why do most college students from rural areas mix poorly?
Posted on 5/8/2018 11:23:57 AM |
Learned, thank you
Posted on 5/8/2018 2:18:50 PM |
Thanks for sharing
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com