mysql -u root -e "show processlist"|grep -i "Locked" >> locklist.txt; for line in awk ‘{print $1}‘ locklist.txt do echo "kill $line;">>lock_kill.sql done
查看mysql数据库表大小
#!/bin/bash database=cms user=root password=‘123456‘ mysql -u${user} -p${password} -e "use $database;show tables;" | sed ‘1d‘ | while read line; do mysql -u$user -p${password} $database -e "SELECT ‘${line}‘,ROUND(SUM(data_length/1024/1024),2) as data_length ,‘MB‘,round(SUM(index_length/1024/1024),2) as index_length,‘MB‘ FROM information_schema.TABLES WHERE information_schema.TABLES.TABLE_SCHEMA = ‘${database}‘ AND information_schema.TABLES.TABLE_NAME = ‘$line‘";done | grep -v data_length | awk ‘{print $1"\t"$2$3"\t"$4$5}‘ | sort -nrk2
本文出自 “从心开始” 博客,请务必保留此出处http://hao360.blog.51cto.com/5820068/1441324