How to monitor MySQL in real-time with mytop

This short guide will explain how to use a free command line utility to monitor a MySQL database in real-time.

mytop is a top-like realtime command line based monitoring system for MySQL. It is written by Jeremy Zawodny, and is available for free download. It runs on most UNIX-based systems, and most definitely on Linux machines. This kind of real-time monitoring can be very useful when administering a MySQL server.

You need a working MySQL server and a few Perl modules such as DBI, DBD::mysql, Term::ReadKey, and Getopt::Long to be able to use mytop. You can download the source code version of mytop from the project’s website, or you can get a pre-built binary package for your distribution. I know that there are packages for Fedora/Redhat and for Ubuntu systems. You should be able to find them pretty easily on the web. Once you get the binary version of mytop install it.

Once you have installed mytop you can check if it is working using the following command:

# mytop -h dbserver -u dbuser -p dbpassword

MySQL on dbserver (5.0.37) up 50+17:53:46 [13:20:38]
Queries: 2.5G qps: 609 Slow: 0.0 Se/In/Up/De(%): 01/00/00/00

Key Efficiency: 99.8% Bps in/out: 0.0/ 0.0

Id User Host/IP DB Time Cmd Query or State
— —- ——- — —- — ———-
9570443 dbuser appdb 0 Prepar
9575575 dbuser appdb 0 Sleep
9576920 dbuser appdb 0 Sleep
9593343 dbuser appdb 0 Sleep
9601720 dbuser appdb 0 Query show full process
9574728 dbuser appdb 1 Sleep
9575771 dbuser appdb 1 Sleep
9579103 dbuser appdb 1 Sleep
9579962 dbuser appdb 1 Sleep
9581070 dbuser appdb 1 Sleep
9585516 dbuser appdb 1 Sleep
9585518 dbuser appdb 1 Sleep
9597503 dbuser appdb 1 Sleep
9597952 dbuser appdb 1 Sleep
9599442 dbuser appdb 1 Sleep

Replace dbserver, dbuser, and dbpassword with the correct credentials of your MySQL server. This ought to get you off the blocks with mytop. You can read up on mytop via the documentation section of the mytop site.

While you’re here, maybe you’d like to check out our other MySQL tips, tricks and tutorials.

If this article helped you, I'd be grateful if you could share it on your preferred social network - it helps me a lot. If you're feeling particularly generous, you could buy me a coffee and I'd be super grateful :)

buy a coffee for

Home » Linux » How to monitor MySQL in real-time with mytop

Leave a Comment

Your email address will not be published. Required fields are marked *