(1)将全部的MySQL连接进程杀掉
for i in `mysql -uroot -pzhangyun -Bse "show processlist" | grep -v "show processlist" | awk '{print $1}'`
do
mysql -uroot -pzhangyun -e "kill $i"
done
注:这里将自身命令的show processlist进程过滤掉
(2)删除指定用户的连接进程
for i in `mysql -uroot -pzhangyun -se "show processlist" | grep -v "show processlist" | awk '{if($2=="zhangyun")print $1}'`
do
mysql -uroot -pzhangyun -e "kill $i"
done
for i in `mysql -uroot -pzhangyun -Bse "show processlist" | grep -v "show processlist" | awk '{print $1}'`
do
mysql -uroot -pzhangyun -e "kill $i"
done
注:这里将自身命令的show processlist进程过滤掉
(2)删除指定用户的连接进程
for i in `mysql -uroot -pzhangyun -se "show processlist" | grep -v "show processlist" | awk '{if($2=="zhangyun")print $1}'`
do
mysql -uroot -pzhangyun -e "kill $i"
done