How do I check, how many ' mySQL connections' a website is using?

myeddie7

Member
Sep 22, 2007
20
1
53
Hello, how do I check, how many ' mySQL connections' a particular website is currently using? Because my client is asking, for his website.
 

rbairwell

Well-Known Member
May 28, 2022
98
42
18
Mansfield, Nottingham, UK
cPanel Access Level
Root Administrator
Under "Server Status->Daily Process Log" you'll be able to see "MySQL — Processes The average number of MySQL® processes for the user." - if you have CloudLinux, the "MySQL Governor" may give more information, but I haven't tried it myself.

If you want more detail, I believe the only way to do this is to turn on the MySQL "General Query Log" under WHM->SQL Services->Edit SQL Configuration->Logs and parse that for connections from that user (say with grep 'mysql_username' /path/to/mysql.log |grep Connect | wc -l ): otherwise get the list of processes using processlist on a regular basis (such as mysqladmin -i 10 processlist which will update the list every 10 seconds or an SQL statement such as SELECT id,user,db,time,state,info from information_schema.processlist.

You could try setting limits manually and see if the user hits those if they are concerned about heavy usage.

I've just found this blog entry which suggests a method of logging connections to a table (I would reproduce the code here, but the Cloudflare security on the forum is blocking me no matter what I do!).
 
  • Like
Reactions: cPRex