强大到没朋友的mysql-shell及插件 https://cloud.tencent.com/developer/article/1676131?areaSource=&traceId=
mysql-shell 是官方出品的运维相关小工具, 目前已经具备很多功能。如果再配合大佬写的插件,简直强大到没朋友。
这里我简单搬运一些常用功能过来。如果想看全面的欢迎订阅 https://lefred.be/ 这个大佬的博客。
大佬写的mysql-shell 插件的地址 https://github.com/lefred/mysqlshell-plugins
安装方法:
$ mkdir -p ~/.mysqlsh/plugins
$ git clone https://github.com/lefred/mysqlshell-plugins.git ~/.mysqlsh/plugins/ext
注意: 我自己测试,这个插件能支持到percona版本8.0.20,在社区版8.0.21上实验失败。
然后,建议再安装下mysql-shell-udr这个插件:
cd /root/
git clone https://github.com/lefred/mysql-shell-udr.git
mkdir /root/.mysqlsh/init.d
mv /root/mysql-shell-udr/* /root/.mysqlsh/init.d
完成上面的2个插件的安装后,我们可以简单试验下效果:
$ mysqlsh dts@192.168.2.4 登录进mysqlsh命令行界面
# 查看我们上面安装的mysql-shell-udr
MySQL 192.168.2.4:33060+ ssl JS > \show
Available reports: alter_progress, gr_info, gr_recovery_progress, locks_info, query, sessions, thread, threads.
MySQL 192.168.2.4:33060+ ssl JS > \show thread
GENERAL
Thread ID: 475282
Connection ID: 198651
Thread type: FOREGROUND
Program name: mysqlsh
User: dts
Host: 192.168.2.4
Database: NULL
Command: Query
Time: 00:00:00
State: executing
Transaction state: NULL
Prepared statements: 0
Bytes received: ?
Bytes sent: ?
Info: SELECT json_object('tid',t.THR ... JOIN information_schema.innodb
Previous statement: NULL
MySQL 192.168.2.4:33060+ ssl JS > \show threads
+--------+--------+------+-------------+------+---------+----------+-----------+---------+-------------------------------------------------------------------+-----------+
| tid | cid | user | host | db | command | time | state | txstate | info | nblocking |
+--------+--------+------+-------------+------+---------+----------+-----------+---------