How to view the current connection number of mysql in real time

1. View the details of all current connections: ./mysqladmin -uadmin -p -h10.140.1.1 processlist 2. Only view the current number of connections (Threads is the number of connections.): ./mysqladmin -uadmin -p -h10.140.1 . 1 status , view the details of all current connections: mysqladmin -uroot -proot processlist D:\MySQL\bin>mysqladmin -uroot -proot processlist +-----+------+----- -------------+---------+---------+------+-------+--- ---------------+

| Id | User | Host | db | Command | Time | State | Info |
+-----+------+----------------+---------+---------+------+-------+------------------+
| 591 | root | localhost:3544 | bbs | Sleep | 25 | | |
| 701 | root | localhost:3761 | | uery | 0 | | show processlist |
+-----+------+----------------+---------+---------+------+-------+------------------+
2. Only view the current number of connections (Threads is the number of connections.): mysqladmin -uroot -proot status D:\MySQL\bin>mysqladmin -uroot -proot status Uptime: 2102 Threads: 3 Questions: 15531 Slow queries: 0 Opens: 0 Flush tab les: 1 Open tables: 61 Queries per second avg: 7.389
3. Modify the maximum number of mysql connections: Open my.ini and modify max_connections= 100 (the default is 100).
Today, there was a sudden increase in the number of connections on a mysql server, and the waiting process was all locked... Because the problem was not solved properly, it was scolded... OTL
summary: In the future, we must quickly locate the error, and arrange the solution
after logging in to the mysql client. You can also use the status command to get the number of thread connections and the id of the current connection,
or use
show full processlist
to see all connected processes, pay attention to check the waiting time of the process and whether the state is locked
. If there are too many processes, print the process, and then check
mysql -e 'show full processlist;' > 111
Find non-locked processes, which is generally the reason why the current execution is stuck, causing subsequent processes to queue up.
In addition, the method of modifying the maximum number of mysql connections:
edit the MySQL (the best combination with PHP) configuration file my.cnf or my.ini
in the [MySQL (the best combination with PHP) d] configuration section and add: max_connections = 1000
Save, restart the MySQL (best combination with PHP) service.
Then use the command: MySQL (the best combination with PHP) admin -uroot -p variables After entering the password of the root database account, you can see | max_connections |1000 |
查看MySQL连接数和当前用户Mysql连接数
先用管理员身份进入mysql提示符。 #mysql -uroot -pxxxx mysql> show processlist; 可以显示前100条连接信息 show full processlist; 可以显示全部。随便说下,如果用普通账号登录,就只显示这用户的。注意命令后有分号。
如果我们想查看这台服务器设置。 #vi /etc/my.cnf set-variable=max_user_connections=30 这个就是单用户的连接数 set-variable=max_connections=800 这个是全局的限制连接数

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325282430&siteId=291194637