要统计数据库的连接数,我们通常情况下是统计总数,细分到每个ip地址:
方法一:
select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
方法二:
mysql -u root -p 123456 -h127.0.0.1 -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c