← 返回命令列表

Linux command

mytop 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Monitor MySQL queries

mytop

Connect to specific database

mytop -u [user] -p [password] -d [database]

Connect to remote server

mytop -h [hostname] -u [user] -p [password]

Slow query mode

mytop -s [5]

Show idle connections

mytop -i

Specify refresh interval

mytop --delay [3]

Batch mode

mytop --batch

Connect via socket

mytop -S [/var/run/mysqld/mysqld.sock]

说明

mytop displays MySQL server activity in real-time, similar to top for processes. It shows running queries, connections, and server statistics. The display includes query threads with their states, execution times, and SQL text. Long-running queries stand out for attention. Server statistics show queries per second, slow queries, threads connected, and cache hit rates. These metrics help identify performance issues. Slow query mode filters display to queries exceeding a time threshold. This focuses attention on problematic operations. The kill command terminates runaway queries. Combined with filtering, it helps manage query overload situations. Connection to remote servers enables monitoring multiple databases from one location.

参数

-u _USER_
MySQL username.
-p _PASS_
MySQL password.
-h _HOST_
MySQL server hostname.
-d _DB_
Default database.
-P _PORT_
MySQL port.
-s _SECONDS_
Slow query threshold.
-i
Show idle connections.
--delay _SECONDS_
Refresh interval.
--color
Use ANSI color.
-S _SOCKET_
MySQL socket path.
--batch
Batch mode (run once, no screen clearing).
--nocolor
Disable ANSI color output.

FAQ

What is the mytop command used for?

mytop displays MySQL server activity in real-time, similar to top for processes. It shows running queries, connections, and server statistics. The display includes query threads with their states, execution times, and SQL text. Long-running queries stand out for attention. Server statistics show queries per second, slow queries, threads connected, and cache hit rates. These metrics help identify performance issues. Slow query mode filters display to queries exceeding a time threshold. This focuses attention on problematic operations. The kill command terminates runaway queries. Combined with filtering, it helps manage query overload situations. Connection to remote servers enables monitoring multiple databases from one location.

How do I run a basic mytop example?

Run `mytop` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -u _USER_ do in mytop?

MySQL username.