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:
- You would need Shell (SSH) access
- You need your MySQL user and password
- 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
- Open your .my.cnf file with your favourite editor:
- Add the following content and update the details accordingly:
[client] user=MySQL-User password=MySQL-PassWord host=MySQL-Host
- 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.