#file: get_innodb_db_size.sh #author: shitou #date: 09/18/2008 #aim: get mysql db table size, especially for Innodb table #use: first replace the db username and password, # #./get_innodb_db_size username db_name [[ $# == 0 ]] && { echo "need the db name and mysql username"; exit 1; } mysql -u $1 -p -e "show table status from $2\G" | \ awk '/(Data_length:|Name:)/{print $0}' | \ awk 'BEGIN{i=1; total=0; print "DB: '"$2"'"; print "-----------------------------------";}; {if(i%2==0){size=$2;printf "%-30s%d\n", table, size} else {table=$2};i++;total+=$2}; END{print "-----------------------------------"; split(i/2, num, "."); printf "TOTAL TABLE:%25d\n", num[1]; printf "TOTAL SIZE:%25d B\n", total}' #EOF
2009-10-30 11:58:19, 1179 reviews, comment
send to mailbox
Shell script to backup all MySQL database
【转载】命令的小总结
MySQL Innodb备份
shell中的数组
一些shell技巧
( ),{ }的区别
一个小命令
awk同时操作两个文件
shell小技巧
awk多维数组
继续凸墙 for Mac OS
json_formatter
mysqlreport详解
少年,不点下广告吗!
all by shitou
blog comments powered by Disqus