#!/bin/bash #定位MySQL中鎖的進程,而後使用kill 殺掉該進程 mysql -u root -e "show processlist" | grep -i "Locked" >> locked_log.txt for line in `cat locked_log.txt | awk '{print $2}'` do echo "kill $line;" >> kill_thread_id.sql done