≡ Menu

HowTo: Monitor What MySQL Server Is Doing

Dear nixCraft,

How can I monitor what my MySQL server is doing?


Confused About MySQL Server

Dear Confused,

To solve MySQL problems or to optimize MySQL server you need to use special tool called mytop. It is a UNIX top command clone for MySQL server. It updates every few seconds, so you can get a reasonable look at your SQL performance. It is capable of displaying a huge amount of information.

Debian / Ubuntu Linux: Install mytop

Use the apt-get command to install the same or download it from official web site
# apt-get install mytop

CentOS / RHEL Linux: Install mytop

First, turn on EPEL repo and type:
# yum install mytop
Sample outputs:

Loaded plugins: auto-update-debuginfo, product-id, protectbase, rhnplugin, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mytop.noarch 0:1.7-3.b737f60.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package             Arch                 Version                          Repository          Size
 mytop               noarch               1.7-3.b737f60.el6                epel                32 k

Transaction Summary
Install       1 Package(s)

Total download size: 32 k
Installed size: 68 k
Is this ok [y/N]: y
Downloading Packages:
mytop-1.7-3.b737f60.el6.noarch.rpm                                           |  32 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mytop-1.7-3.b737f60.el6.noarch                                                   1/1 
Installed products updated.
  Verifying  : mytop-1.7-3.b737f60.el6.noarch                                                   1/1 

  mytop.noarch 0:1.7-3.b737f60.el6                                                                  


How do I use mytop command?

The syntax is as follows:


In this example, connect using admin username and password as 123456:
$ mytop -u admin -p 123456
Sample outputs:

You can also specify a database name such as foobar to monitor:
$ mytop -u admin -p 123456 -d foobar

Finally, you can store this information in a config file called ~/.mytop file:
$ cat ~/.mytop
Sample outputs:


mytop is capable of displaying a large amount of information and it supports lots of keyboard shortcut too, so be sure to read the man page and documentation of mtop.


Share this on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 0 comments… add one }

Leave a Comment

   Tagged with: , , , , , , ,