Monitor MySQL Processes at the Command Line

black and gray laptop computer
Photo by luis gomes on Pexels.com

Here are two ways you can get a rolling view on MySQL processes from the Linux command line.

mysqladmin

mysqladmin -u root -p -i 1 processlist

Replace root in the above example with your MySQL username and, after giving your password when prompted, you will see the processlist being output over and over again on screen.

You can pipe the output of this process into a file or any other command line utility.

watch & mysql

It’s also possible to use the command watch to run the processlist command over and over again, but you will need to enter your password into the command line itself to do this, which is insecure.

watch 'mysql -u root --password=rootpassword -e "show processlist"'

This will use the watch command to run the processlist command over and over again. This gives a slightly nicer output to screen in my opinion, but does include a warning about the risks of putting your password into the commandline!

Be the first to comment

Leave a Reply