查看连接MYSQL数据库的IP信息

实现方式有以下三种:

第一种:

mysql> select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
+--------------+----------+
| ip           | count(*) |
+--------------+----------+
| 172.17.0.7   |        2 |
| 192.168.6.23 |       10 |
| localhost    |        3 |
+--------------+----------+
3 rows in set (0.03 sec)

第二种:

mysql -u root -p  -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c


      2  172.17.0.7
     10  192.168.6.23
      3  localhost

第三种:

mysql -u root -p --skip-column-names -e "show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq –c

 

你可能感兴趣的:(Linux,SQL,mysql,mysql,linux)