Monitor MySQL Processlist in (almost) Real-Time

Monitor MySQL Processlist in (almost) Real-Time


This is a pretty easy way to monitor your MySQL processlist in real-time even on shared hosting platforms.

Please note that this article is specifically for Linux servers.

There are a few things that you need before you start:

  1. You would need Shell (SSH) access
  2. You need your MySQL user and password
  3. You need your MySQL host, in most cases it is localhost but depending on the platform it might be different

Once you have the above ready just follow these steps here:

  • SSH to your server
ssh [email protected]
  • Open your .my.cnf file with your favourite editor:
 vim ~/.my.cnf 
  • Add the following content and update the details accordingly:
  • To be on the safe side set secure permissions to the newly created file:
 chmod 400 ~/.my.cnf 
  • This is pretty much it, all you would need to run is the following:
 watch -n0.5 'mysql -e "show full processlist;"'

That way you would monitor all of the MySQL processes for the user that you've specified in your .my.cnf file in real time without having to type your password each time even on shared servers.

Hope that this helps.

If you have any questions please feel free to contact me at any time.