Detailed explanation of the method of viewing the current connection number of mysql
- 2021-12-04 20:04:25
- OfStack
1. View the details of all current connections:
./mysqladmin-uadmin-p-h10.140. 1.1 processlist2, just look at the current number of connections (Threads is the number of connections.):
./mysqladmin-uadmin-p-h 10.140. 1.1 status
To view 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. Just look at 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.3893, Modified mysql Maximum Connections:
Open my. ini and modify max_connections=100 (default is 100).
Today, one mysql server suddenly has a sudden increase in the number of connections, and all the waiting processes are locked... because the problem is not solved properly, resulting in being scolded... OTL
Summary: Quickly locate errors and lay out solutions in the future
After logging in to the mysql client, you can also get the number of thread connections and the currently connected id using the status command
Or use
show full processlist
Look at all connected processes under 1, and pay attention to the waiting time of the process and whether the state is locked
If there are too many processes, print them out and view them
mysql -e 'show full processlist;' >
111 Find non-locked process, 1 is the current execution jammed, resulting in the following process queuing reasons.
In addition, modify the method of mysql maximum connection number:
Edit the MySQL (best combination with PHP) configuration file
my. cnf or my. ini
In the [MySQL (best combination with PHP) d] configuration section, add:
max_connections = 1000 Save and restart the MySQL (the best combination of PHP) service.
Then use the command: What is the best abortion operation in Wuxi http://www.120csjlyy. com/
MySQL (the best combination with PHP)
admin -uroot -p variables
You can see it after entering the password of root database account
max_connections 1000 View the number of MySQL connections and the number of current user Mysql connections
Enter the mysql prompt as an administrator first.
#mysql -uroot -pxxxx
mysql > show processlist; Can display the first 100 connection information show full processlist; All can be displayed. By the way, if you log in with an ordinary account, only the user's. Notice that there is a semicolon after the command.
If we want to view the settings of this server.
#vi /etc/my.cnfset-variable=max_user_connections=30
This is the number of connections for a single user set-variable=max_connections=800
This is the global limit on the number of connections
Summarize