mytop
Monitor system processes in real-time
TLDR
Start mytop
Connect with a specified username and password
Connect with a specified username (the user will be prompted for a password)
Do not show any idle (sleeping) threads
SYNOPSIS
mytop [options]
Example: mytop -u user -p password -h localhost -d database_name
PARAMETERS
-u, --user=name
Specify the MySQL username for connection.
-p, --password[=pass]
Provide the MySQL password. If not provided, mytop will prompt for it. Avoid passing on the command line for security.
-h, --host=host
Connect to the MySQL server on the specified host.
-P, --port=port
Specify the TCP/IP port number for the connection.
-s, --delay=seconds
Set the delay between screen updates in seconds (default is 5 seconds).
-d, --database=db
Specify the default database to use once connected.
-b, --batch
Run in batch mode (non-interactive), typically used for scripting or output redirection.
-i, --idle
Show idle connections/threads in the display. By default, idle threads may be filtered.
-V, --version
Display version information and exit.
-?, --help
Show a help message and exit.
DESCRIPTION
mytop is a free, open-source, console-based monitoring program designed specifically for MySQL and MariaDB databases. It provides a real-time, interactive view of database activity, analogous to how top
monitors system processes. Users can observe current queries, active connections, uptime, load, buffer usage, and other crucial performance metrics at a glance. It's particularly useful for database administrators and developers to quickly identify performance bottlenecks, long-running queries, or abnormal database behavior directly from the terminal. mytop connects to the MySQL server and periodically fetches and displays information about its status, threads, and variables, allowing for quick diagnostics without relying on graphical tools.
CAVEATS
While mytop is highly functional, it has a few considerations:
1. Password Security: Providing passwords directly on the command line (e.g., -pmypass
) can expose them in process lists. It's safer to use a configuration file (~/.my.cnf
) or allow mytop to prompt for the password.
2. Development Status: Its development might be less active compared to some newer, more feature-rich monitoring solutions, but it remains highly effective for its core purpose.
CONFIGURATION FILES
mytop can read connection parameters from standard MySQL client configuration files (e.g., ~/.my.cnf
or /etc/my.cnf
). Parameters can be placed under the [client]
or [mytop]
sections, allowing for more secure password handling and simplified invocation.
INTERACTIVE COMMANDS
While mytop is running, it supports various interactive commands similar to top
. Common commands include:
k: Kill a selected MySQL thread.
f: Toggle full query display.
o: Change the order of displayed columns.
d: Change the update delay.
q: Quit mytop.
HISTORY
mytop was created as a simple, terminal-based alternative to graphical MySQL monitoring tools, drawing direct inspiration from the Unix top
utility. It gained popularity for its lightweight nature and efficiency in providing real-time database insights without significant overhead. Initially developed in the early 2000s, it has been maintained to support newer versions of MySQL and MariaDB, remaining a staple in many database administrators' toolkits for quick diagnostics and performance troubleshooting.
SEE ALSO
top(1), htop(1), mysql(1), mysqladmin(1)