Mysqladmin Mysql 管理工具

Mysqladmin 是 Mysql 自带的管理工具,我们常用它来做密码变更、检测 Mysql 是否存活、Mysql 状态查看等等。

1、查看帮助信息

点击(此处)折叠或打开

  1. [root@Mysql ~]# mysqladmin --help ## 可以使用 --help 输出帮助信息,这里就不贴了

2、检测 Mysql 是否存活

点击(此处)折叠或打开

  1. [root@Mysql ~]# mysqladmin -uroot -p123456 ping ## 可以看到提示信息 " mysql is alive " 。
  2. Warning: Using a password on the command line interface can be insecure.
  3. mysqld is alive

  4. [root@Mysql ~]# mysqladmin -uroot -p123456 ping ## 当 Mysql 停止时,可以看到提示 " 连接 Mysql 失败 ",可以通过 $? 、检索 alive / failed 来判断。
  5. Warning: Using a password on the command line interface can be insecure.
  6. mysqladmin: connect to server at 'localhost' failed
  7. error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
  8. Check that mysqld is running and that the socket: '/tmp/mysql.sock

3、查看 Mysql 状态

点击(此处)折叠或打开

  1. [root@Mysql ~]# mysqladmin -uroot -p123456 status
  2. Warning: Using a password on the command line interface can be insecure.
  3. Uptime: 13 Threads: 1 Questions: 2 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.153

  4. ## Mysql 总运行时间,秒
  5. ## 活跃线程( 客户 )数
  6. ## 服务器启动以来客户查询数
  7. ## 慢查询数
  8. ## 服务器已经打开的数据表数
  9. ## 服务器已经执行 flush 、refresh 、reload 命令数
  10. ## 目前打开的表数
  11. ## 自上次运行计算,平均每秒查询次数

4、查看 Mysql 的连接线程信息

点击(此处)折叠或打开

  1. [root@Mysql ~]# mysqladmin -uroot -p123456 processlist
  2. Warning: Using a password on the command line interface can be insecure.
  3. +----+------+-----------+----+---------+------+-------+------------------+
  4. | Id | User | Host | db | Command | Time | State | Info |
  5. +----+------+-----------+----+---------+------+-------+------------------+
  6. | 2 | root | localhost | | Query | 0 | init | show processlist |
  7. +----+------+-----------+----+---------+------+-------+------------------+

5、还可以关闭服务 shutdown 、打印版本信息 version 、杀死线程 kill id 、重载授权表 reload 、打印可用变量 variables 等等~~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值