ubuntu 安装使用 mytop
apt搜索一下
$ sudo apt search mytop Sorting... Done Full Text Search... Done mytop/focal,focal,now 1.9.1-4 all top like query monitor for MySQL
然后安装一下
sudo apt-get install mytop
直接执行 mytop 报错
$ mytop Cannot connect to MySQL server. Please check the: * database you specified "" (default is "") * username you specified "root" (default is "root") * password you specified "" (default is "") * hostname you specified "localhost" (default is "localhost") * port you specified "3306" (default is 3306) * socket you specified "" (default is "") The options my be specified on the command-line or in a ~/.mytop or ~/.my.cnf config file. See the manual (perldoc mytop) for details. Here's the exact error from DBI. It might help you debug: Access denied for user 'root'@'localhost' (using password: NO)
说我没有找到 .mytop 或者 my.cnf 文件,那么这个文件应该怎么配置呢?通过find寻找发现了跟mytop有关的文件夹
$ sudo find / -name "mytop" find: ‘/proc/2308/task/2308/net’: Invalid argument find: ‘/proc/2308/net’: Invalid argument find: ‘/run/user/1001/doc’: Permission denied find: ‘/run/user/1001/gvfs’: Permission denied /usr/bin/mytop /usr/share/doc/mytop
这个就是可执行文件,不是它
$ ll /usr/bin/mytop -rwxr-xr-x 1 root root 60K 1月 10 2017 /usr/bin/mytop*
发现这个有配置,然后查看一下这个默认配置有个参考
$ ll /usr/share/doc/mytop total 12K -rw-r--r-- 1 root root 2.2K 1月 10 2017 changelog.Debian.gz -rw-r--r-- 1 root root 1.3K 1月 10 2017 copyright -rw-r--r-- 1 root root 871 1月 10 2017 mytop.sample.conf
发现了这个 simple conf 。好了,如此以来应该是要按这个配置,看一下它的内容
# Copy this file to ~/.mytop and customize it to your own needs # Username to use when logging in to the MySQL server user=root # Password to use when logging in to the MySQL server pass= # Hostname of the MySQL server. host=localhost # Port number of the MySQL server. port=3306 # Connect to specific database by default. db=test # How long between display refreshes. delay=5 # Use direct socket instead of TCP/IP network to connect to the MySQL server. socket= # Run mytop only once and than exit. batchmode=0 # Display headers or not. header=1 # Use colors if available. color=1 # Display idle threads. idle=1 # Resolve IP addresses to names. resolve=1 # Compact large numbers for better readability, e.g. 10.000 -> 10.0k. long=0 # Reverse sort order from ascending to descending using Idle time. sort=0 # Use vt100 escape sequences to reduce screen flicker. vt100=0
然后配置一份文件到
touch ~/.mytop
这个文件里面配置如下内容
# Copy this file to ~/.mytop and customize it to your own needs # Username to use when logging in to the MySQL server user=root # Password to use when logging in to the MySQL server pass=密码 # Hostname of the MySQL server. host=localhost # Port number of the MySQL server. port=3306 # Connect to specific database by default. db=test # How long between display refreshes. delay=5 # Use direct socket instead of TCP/IP network to connect to the MySQL server. socket=/tmp/mysql.sock # Run mytop only once and than exit. batchmode=0 # Display headers or not. header=1 # Use colors if available. color=1 # Display idle threads. idle=1 # Resolve IP addresses to names. resolve=1 # Compact large numbers for better readability, e.g. 10.000 -> 10.0k. long=0 # Reverse sort order from ascending to descending using Idle time. sort=0 # Use vt100 escape sequences to reduce screen flicker. vt100=0
如此以来就配置好了。重新启动一下看看。
$ mytop
得到
这样以来就可以用它监控mysql 的 qps 了
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
2017-09-22 用代码实现表情包
2015-09-22 php类获取静态变量值以及调用