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:
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.
|