Monitoring active MySQL queries


Monitoring a MySQL database is a frequent task, especially if your system is under load. What if you wanted to have a quick look at what's going on?


If you are allowed to install applications, you can use mytop. If you are using Ubuntu or Debian, you can simply run sudo apt-get install mytop and you're done.

Type mytop in your console window and you'll see an output like this:

MySQL on localhost (5.7.15)                                                     load 0.24 0.17 0.07 3/325 10959 up 36+07:52:44 [08:16:02]
 Queries: 256.2k   qps:    0 Slow:    10.0         Se/In/Up/De(%):    88/00/00/00

 Key Efficiency: 96.4%  Bps in/out:  13.3/133.9

       Id      User         Host/IP         DB       Time    Cmd    State Query
       --      ----         -------         --       ----    ---    ----- ----------
     9440 70b2caa8d localhost:16204 mysqlrecip          4  Query executin SELECT BENCHMARK(10000000,ENCODE('
     9443      root       localhost                     0  Query starting show full processlist

If you don't have the permission to install a tool, you can simply run the following query to see all currently active processes:

SELECT * FROM information_schema.processlist


Please sign-in to post a comment