Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 44 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

A powerful MySQL and MariaDB monitoring tool for the command line, **mytop** displays real-time database server performance information similar to `top`.


## Current Version

**v2.0** - released on Feb 3rd, 2026

---

## I know mytop - just show me how to install it

1. Clone the repo, make mytop executable and copy it into /usr/local/sbin/
```bash
cd ~/; git clone https://github.com/fevangelou/mytop.git; cd mytop; chmod +x mytop; cp -f mytop /usr/local/sbin/
```
1. Clone the repo, make mytop executable and copy it into `/usr/local/sbin/`

```bash
cd ~/; git clone https://github.com/fevangelou/mytop.git; cd mytop; chmod +x mytop; cp -f mytop /usr/local/sbin/
```

2. Run anywhere (the defaults work just fine on Debian 11+, Ubuntu 22.04+ and RHEL distros v7 or newer)
```bash
mytop
```

```bash
mytop
```

---

Expand All @@ -32,50 +34,56 @@ It is not a half-baked todo-when-I-get-the-time fork.

As a day & night sysadmin, I use mytop... daily. Or at least, I did. My gradual switch to Ubuntu Server 24.04 left me with Innotop, which simply does not work right (especially when it comes to explaining queries - plus it never "clicked" as you had to configure it just for the basics you get from mytop out of the box - go figure). As such, forking mytop was the only sensible thing to do. And as long as I'm active as a sysadmin (17+ years already), I'll keep it updated.

Yes, it has been "vibe coded" with the help of Anthropic's Claude (Perl was never my domain), but I have tested it extensively and since it's a daily tool for me, I'm gonna keep on maintaining it, as well as examine a possible rewrite to amother language.
Yes, it has been "vibe coded" with the help of Anthropic's Claude (Perl was never my domain), but I have tested it extensively and since it's a daily tool for me, I'm gonna keep on maintaining it, as well as examine a possible rewrite to another language.

Sincere thanks to Jeremy D. Zawodny (original author) & Mark Grennan (updated it for MySQL 5.x).

*P.S. Whoever said AI is killing open source is wrong. Needs and ways have just shifted. Embrace the new tooling.*


## WHAT'S NEW

### MySQL 8.0 & MariaDB 10.3 (or newer) compatibility fixes

#### Query Cache Removal

- MySQL 8.0 completely removed the query cache feature
- Added intelligent detection that checks for `have_query_cache` variable
- Falls back to checking `Qcache_hits` status variable for older versions
- Safely defaults to disabled for MySQL 8.0 or newer

#### Safe Status Variables

- All `Qcache_*` status variable references now use null coalescing
- Prevents undefined variable warnings when query cache doesn't exist
- Cache hit ratio calculations won't crash on MySQL 8+

#### Enhanced EXPLAIN

- Wrapped EXPLAIN execution in eval block for proper error handling
- Catches non-explainable queries (DDL, some admin commands)
- Added support for new `filtered` column in MySQL 8+ EXPLAIN output
- Dynamic column detection for future MySQL versions

#### System Compatibility

- Fixed `/proc/loadavg` reading for non-Linux systems
- Added proper error handling with fallback to empty string

### User Experience Improvements

#### Dependency Checking

- Automatic detection of missing Perl modules (DBI, DBD::mysql, Term::ReadKey)
- Provides exact installation commands based on your distribution

#### Better Defaults

- Default database changed from `test` to `mysql`
- Refresh delay reduced from 5 seconds to 1 second
- Idle thread display threshold set to 2

#### Code Quality

- Fixed all Perl syntax warnings
- Renamed conflicting variables to avoid masking
- Fixed operator typo (`=>` to `>=` in cache ratio comparison)
Expand All @@ -90,21 +98,25 @@ Sincere thanks to Jeremy D. Zawodny (original author) & Mark Grennan (updated it
mytop requires the following Perl modules:

#### On Debian 11+ or Ubuntu 22.04+

```bash
sudo apt install libdbi-perl libdbd-mysql-perl libterm-readkey-perl
```

#### On RHEL distros (v7 or newer)

```bash
sudo yum install perl-DBI perl-DBD-MySQL perl-TermReadKey
```

or

```bash
sudo dnf install perl-DBI perl-DBD-MySQL perl-TermReadKey
```

#### Via CPAN (for the purists)

```bash
cpan DBI DBD::mysql Term::ReadKey
```
Expand All @@ -114,7 +126,6 @@ cpan DBI DBD::mysql Term::ReadKey
No need to run `make` and `make install` as with previous versions - mytop is a standalone Perl script:

```bash

# 1. Clone the repo, make mytop executable and copy it into /usr/local/sbin/
cd ~/; git clone https://github.com/fevangelou/mytop.git; cd mytop; chmod +x mytop; cp -f mytop /usr/local/sbin/

Expand All @@ -124,6 +135,7 @@ mytop
```

#### Hint: If you have an older mytop version already installed on your system and you wanna use this new version in parallel, just name it mytop2 when moving it, e.g.:

```bash
cd ~/; git clone https://github.com/fevangelou/mytop.git; cd mytop; chmod +x mytop; cp -f mytop /usr/local/sbin/mytop2
```
Expand Down Expand Up @@ -274,6 +286,7 @@ mytop --batch
*This changelog provides a historical record of all previous versions.*

### Version 2.0 - February 3rd, 2026

MySQL 8.0 & MariaDB 10.3 or newer compatibility patches

- Fixed query cache detection for MySQL 8.0+ (query cache was removed)
Expand All @@ -290,6 +303,7 @@ MySQL 8.0 & MariaDB 10.3 or newer compatibility patches
- Fixed all Perl syntax warnings and code quality issues

This version is fully compatible with:

- MySQL 5.x (with query cache)
- MySQL 8.0+ (without query cache)
- MariaDB 10.3+
Expand All @@ -298,6 +312,7 @@ This version is fully compatible with:
Version 2.0 was based off v1.91 from Mark Grennan.

### Version 1.9.1 - February 14, 2012 (Mark Grennan)

- Added display of system load level on the top line
- Added Readonly state and Delay to the replication line
- Added monitoring of Slave status
Expand All @@ -307,6 +322,7 @@ Version 2.0 was based off v1.91 from Mark Grennan.
- New command 'M' to change [mode] to status show changes

### Version 1.8 - May 21, 2010 (Mark Grennan)

- Added fixes for changes in MySQL 5.1 and 64-bit systems
- Completed TODO - "make 'C' toggle display color"
- New command 'S' command: Highlights slow queries less than 'S' seconds (default: 10 seconds)
Expand All @@ -316,9 +332,11 @@ Version 2.0 was based off v1.91 from Mark Grennan.
- Fixed documentation errors

### Version 1.6 - February 16, 2007

- Added support for passwords with embedded spaces (patch from Jeffrey Friedl)

### Version 1.4 - August 3, 2003

- Used junk query filter from Steven Roussey
- Added -prompt option so password doesn't need to be on command-line or in script (patches from jon r. luini and Sean Leach)
- Added -resolve support to convert IPs to hostnames in thread view (patch from Yogish Baliga)
Expand All @@ -331,6 +349,7 @@ Version 2.0 was based off v1.91 from Mark Grennan.
- Various other cleanup and fixes

### Version 1.3 - April 17, 2003

- Added "c" command to switch between thread view and "command summary" view
- Command summary pulls Com_* values from SHOW STATUS
- Fixed various bugs
Expand All @@ -340,15 +359,18 @@ Version 2.0 was based off v1.91 from Mark Grennan.
- Use Com_select rather than Questions to calculate Qcache ratio (only SELECT queries are cache candidates)

### Version 1.2 - October 27, 2002

- Better handle MySQL server going offline (shouldn't die with illegal division by zero errors)
- Make Host column large enough to handle IP addresses (suggestion from Jeremy Tinley)
- Added query cache stats

### Version 1.1 - Not Released

- Updated option handling so both --pass and --password work (suggested by Paul DuBois)
- Noted that OS X is supported

### Version 1.0 - April 27, 2002

- Fixed cases when trying to remove domain name from display even if it's an IP address
- Fixed formatting bugs and "use of uninitialized value" errors
- Adjusted column widths and headings
Expand All @@ -359,34 +381,41 @@ Version 2.0 was based off v1.91 from Mark Grennan.
- Changed "Query Info" column to "Query or State"
- Real-time queries/sec computed using Time::HiRes if available
- Added 'e' key to EXPLAIN a query
- Moved website to http://jeremy.zawodny.com/mysql/mytop/
- Moved website to <http://jeremy.zawodny.com/mysql/mytop/>
- Created mailing list

### Version 0.9

- Set $0 to 'mytop' to make it easier to spot
- Included README in distribution

### Version 0.8

- Added "Queries Per Second" (qps) mode - press 'm' key
- Distributed as a true Perl package with Makefile.PL
- Can be installed via CPAN shell

### Version 0.7

- Basic support for Windows (screen clearing doesn't work)

### Version 0.6

- Minor code cleanup

### Version 0.5

- Fixed some field widths to handle larger values

### Version 0.4

- Added -P command-line argument (to specify port number)
- Fixes for better output on small terminals
- Added 'i' hotkey to toggle display of Idle (sleeping) threads
- Other minor updates

### Version 0.3

- Updated documentation to reflect command-line arguments
- Added support for long and short command-line arguments
- Optional color support via Term::ANSIColor
Expand All @@ -401,6 +430,7 @@ Version 2.0 was based off v1.91 from Mark Grennan.
- Added more specific error messages from DBI on connect failure

### Version 0.2

- Added support for non-standard port numbers

---
Expand All @@ -416,9 +446,9 @@ GNU General Public License
### Core Contributors

- **Jeremy D. Zawodny** - Original author and maintainer (2000-2009)
- http://jeremy.zawodny.com/mysql/mytop/
- <http://jeremy.zawodny.com/mysql/mytop/>
- **Mark Grennan** - MySQL 5.x updates and enhancements (2010-2012)
- https://www.mysqlfanboy.com/mytop-3/
- <https://www.mysqlfanboy.com/mytop-3/>
- **Fotis Evangelou (vibe coded with Claude)** - Updated to support MySQL 8.0 & MariaDB 10.3 or newer releases (2026+)

---
Expand Down