Home  >  Article  >  Database  >  如何查看连接MYSQL数据库的IP信息_MySQL

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

WBOY
WBOYOriginal
2016-06-01 12:59:251379browse

我们通常情况下要统计数据库的连接数指的是统计总数,没有细分到每个IP上。现在要监控每个IP的连接数,实现方式如下:

方法一:

代码如下:

select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;


方法二:

代码如下:

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

方法三:

代码如下:

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


以上就是三种监控IP连接数的实现方式,希望对大家的学习有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn