mysql数据清理
dbname:mytest
表特征:my_table_test_20140701
#!/bin/sh
dbname="mytest"
for month in ` seq -f %02g 1 7`;do
mysql -h"$ip" -u -p $dbname -s -e "show tables like ‘%2014${month}%‘;" >tablelist_${month}.txt
sed -i ‘/Tables_in_mytest/d‘ /data/tablelist_*.txt ;#mytest 为dbname
for tablename in `cat /data/tablelist_*.txt`
do
mysql -h"$ip" -u -p $dbname -s -e \
"
drop table $tablename;
"
done
本文出自 “运维者说:从菜鸟到老鸟” 博客,请务必保留此出处http://liuqunying.blog.51cto.com/3984207/1560347