MySQL Primer--the Usage of Mysqladmin--ping,status,processlist,kill,shutdown

1.Using mysqladmin
  *Checking  MySQL server status
    command:
       mysqladmin -p ping;
       mysqladmin -p status;

 

  eg1:

     fish@piniheaven:~$sudo mysqladmin -p ping
     [sudo] password for fish:
     Enter password:
     mysqld is alive
   
   eg2:
     fish@piniheaven:~$ sudo mysqladmin -p status
     Enter password:
     Uptime: 3272  Threads: 1  Questions: 111  Slow queries: 0  Opens: 175  Flush tables: 1  Open tables: 42  Queries per second avg: 0.033

 
  *find out what connections are active to the MySQL server
     command:
       mysqladmin -p processlist;

 

  eg3:

     fish@piniheaven:~$ sudo mysqladmin -p processlist
     Enter password:
       +----+------+-----------+------------+---------+------+-------+------------------+
       | Id  | User | Host      | db         | Command | Time | State | Info         |
       +----+------+-----------+------------+---------+------+-------+------------------+
       | 46 | root | localhost | MyDatabase | Sleep   | 100  |       |                  |
       | 50 | root | localhost |            | Query   | 0    |       | show processlist |
      +----+------+-----------+------------+---------+------+-------+------------------+
    explanation:
           From above, we can see a user named root is connected from localhost to the MyDatabase database


   *kill a connection
     command:
        mysqladmin kill <id>

 

 eg4:

     fish@piniheaven:~$sudo mysqladmin -p kill 46
     Enter password:
     fish@piniheaven:~$ sudo mysqladmin -p processlist
     Enter password:
      +----+------+-----------+----+---------+------+-------+------------------+
     | Id | User | Host      | db | Command | Time | State | Info         |
     +----+------+-----------+----+---------+------+-------+------------------+
     | 52 | root | localhost |    | Query   | 0    |       | show processlist |
     +----+------+-----------+----+---------+------+-------+------------------+
    explanation:
       after executing the command,we can see that the connection by id 46  no longer exists:
       At the sametime,when the root user with an id 46 who connected via the MySQL CLI try to do someting,for example:
       SHOW DATABASES;Unfortunately,it didn't work!He would received the following messages:
       ERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...
 
  *shoutdown the server
     command:
       mysqladmin -p shutdown
   
       
         






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值