如何查看連接MYSQL數(shù)據(jù)庫的IP信息
2015-09-07 16:06:43
12725
我們通常情況下要統(tǒng)計(jì)數(shù)據(jù)庫的連接數(shù)指的是統(tǒng)計(jì)總數(shù),沒有細(xì)分到每個(gè)IP上?,F(xiàn)在要監(jiān)控每個(gè)IP的連接數(shù),實(shí)現(xiàn)方式如下:
方法一:代碼如下:
select SUBSTRING_INDEX(host,:,1) as ip , count(*) from information_schema.processlist group by ip;
方法二:
代碼如下:
mysql -u root -h127.0.0.1 -e "show processlistG;"| 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