关闭指定ip的连接:
for i in $(mysql -uusername -ppassword -Bse "select * from information_schema.processlist where HOST like 'ip_addr%'" | awk '{print $1}');do mysql -uusername -ppassword -e "kill $i";done
下文摘自:mysql 清除连接
清除所有连接
for i in $(MySQL -h192.168.10.101 -uwebuser -pwebuser@123 -Bse "show processlist" | awk '{print $1}');do mysql -h192.168.10.101 -uwebuser -pwebuser@123 -e "kill $i";done
清除admin的所有连接
for i in $(mysql -h192.168.10.101 -uwebuser -pwebuser@123 -Bse "show processlist" | awk '{if($2=="admin")print $1}');do mysql -h192.168.10.101 -uwebuser -pwebuser@123 -e "kill $i";done