• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Wednesday, June 25, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

Using Mytop to Monitor MySQL Performance

How VPS by How VPS
January 1, 2020
in Linux
0
0
SHARES
39
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Prerequisites
  3. Step one: Install mytop using EPEL yum repository
  4. Step two: Configure mytop with a customized configuration file
  5. Step three: Use mytop to monitor MySQL performance
  6. Want to contribute?


Introduction

Mytop is a free console-based tool for monitoring performance of MySQL. It is similar to the “top” utility, but it displays MySQL queries. With mytop, you can instantaneously monitor MySQL uptime, threads, queries, users’ behaviors and other real-time status information, which can be helpful for MySQL performance optimization.

In this tutorial, I will show you how to install, configure, and use mytop on a newly-created Vultr server based on the One-Click LEMP Application.

Prerequisites

Before proceeding, you need to:

  • Deploy a server instance with the One-Click LEMP Application.

  • Log in as a non-root user with sudo privileges. You can find how to create a non-root user in this article.

Step one: Install mytop using EPEL yum repository

With the help of EPEL (Extra Packages for Enterprise Linux) yum repository, you can easily install mytop on your server. By default, the EPEL yum repository has been installed when using the One-Click LEMP Application.

You can confirm the EPEL repository’s existence with:

sudo yum repolist

You will see the epel Extra Packages for Enterprise Linux 6 - x86_64 repository listed.

To protect packages in the EPEL repository from being updated or overridden by packages in other repositories, you need to install the “protectbase” plugin:

sudo yum install yum-plugin-protectbase.noarch -y

Then edit the file /etc/yum.repos.d/epel.repo, input:

cd /etc/yum.repos.d
sudo vi epel.repo

Append a line protect=1 to the section [epel]:

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
protect=1

Save and close the file.

Finally, install mytop with:

sudo yum install mytop -y

Step two: Configure mytop with a customized configuration file

To simplify the usage of mytop, you can create a customized configuration file named /root/.mytop. When you run mytop as root or a non-root user with sudo privileges, the program will invoke this configuration file automatically. If you want to run it as a non-root user without sudo privileges, you need to put the configuration file in the non-root user’s home directory.

For your reference, here is a sample of the configuration file /root/.mytop:

user=root
pass=
host=localhost
db=mysql
delay=5
port=3306
socket=
batchmode=0
header=1
color=1
idle=1

The contents in this file provide default arguments to the mytop program, reducing your manual input when using it. However, if you run the program with arguments manually inputted, the command-line arguments will override corresponding arguments in the configuration file.

You can modify these arguments according to your specific conditions. Some of the meanings of the arguments are listed below:

  • user: The database username.
  • pass: The password for the database user. For security purposes, you can leave it blank and input the password manually.
  • host: The database host address.
  • db: The database name.
  • delay: Display refresh interval in seconds.

Full explanations for each argument can be found in the manual page:

man mytop

Step three: Use mytop to monitor MySQL performance

As mentioned before, the mytop utility use both arguments in configuration file and command line arguments, and the latter will override the former accordingly.

Thus, with a configuration file in order, you just need to input the command with few arguments.

For example, if you want to input your password with a prompt for better security, you can input:

sudo mytop --prompt

Then input the password for the default database and user root, which can be found in /root/.my.cnf, to enter the mytop program interface.

Here is another example. If you want to monitor a specific database, you can use:

sudo mytop -d yourdatabasename --prompt

Replace yourdatabasename with your own one.

In the mytop program interface, you will find something like:

MySQL on localhost (5.6.26-log)                                                  up 0+08:36:33 [12:07:15]
 Queries: 921.0  qps:    0 Slow:     0.0         Se/In/Up/De(%):    00/00/00/00
             qps now:    0 Slow qps: 0.0  Threads:    1 (   1/   0) 00/00/00/00
 Key Efficiency: 100.0%  Bps in/out:   0.8/140.7   Now in/out:   9.7/ 1.9k

      Id      User         Host/IP         DB      Time    Cmd Query or State
       --      ----         -------         --      ----    --- ----------
       14      root       localhost      mysql         0  Query show full processlist

This is the default thread view of mytop, you can always switch to this view by pressing t.

The top four lines constitute the header which can be toggled on or off by pressing Shift + h. The header contains general information about your MySQL server.

Beneath the header, you can see the status data of current MySQL threads.

To get help, press ? (Shift + /) when the program is running.

To quit the program, press q.

More details about the display and usage of mytop can be found in its man page:

man mytop

That’s it. You can use the data gathered from mytop to implement informed MySQL optimization.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Gitea on Fedora 29

Next Post

Install MediaWiki on the One-Click LEMP Application

Next Post

Install MediaWiki on the One-Click LEMP Application

Leave a Reply Cancel reply

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

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In