mysql -uroot -poRcl_123 -Dsnsdb_test -e "select host from user;"
mysql -uroot -poRcl_123 -Dmysql -e "show variables like '%Thread%';"
mysql -uroot -poRcl_123 -Dmysql -e "show status like '%Threads_connected%';"
mysql -uroot -poRcl_123 -Dmysql -e "show status;"
mysql -uroot -poRcl_123 -Dmysql -e "show variables like 'max_connections';"
mysql -uroot -poRcl_123 -Dmysql -e "show full processlist \G;"
mysql -uroot -poRcl_123 -Dmysql -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c
使用grep过滤
mysql -uroot -poRcl_123 -Dmysql -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c | grep 192.168.10.45
//查看占用的总的数据库连接数
mysql -uroot -poRcl_123 -Dmysql -e "select count(*) from information_schema.PROCESSLIST;"
select count(*) from information_schema.PROCESSLIST
mysql -uroot -poRcl_123 -Dmysql -e "show global status like 'Max_used_connections';"
//循环输出
while true;do mysql -uroot -poRcl_123 -Dmysql -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c;echo "******************************************";sleep 1;done
mysql -uroot -poRcl_123 -Dmysql -e "show variables" | grep max_connections
mysql -uroot -poRcl_123 -Dmysql -e "show status;"
netstat -anp | grep 3306 | grep 192.168.10.99 | wc -l
mysql -uroot -poRcl_123 -Dmysql -e "show variables like 'max_connections';"
mysql -uroot -poRcl_123 -Dmysql -e "show variables like 'max_connections';"
mysql -uroot -poRcl_123 -Dmysql -e "select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;"
mysql -uroot -poRcl_123 -Dmysql --skip-column-names -e"show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq -c
mysql -uroot -poRcl_123 -Dmysql -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c