说明,此方法只适合数据库库中表的记录数是较小的情况下,线上可以考虑采用,要是数据库的表特别的大的话,就不要采用此方法了,负责会导致mysql的服务器的负载特别的高,有可能导致服务器被挂掉的风险。
for n in `mysql -uroot -p‘12334‘ -e "use novel;show tables;"|sed ‘1d‘`;do echo $n; mysql -uroot -p‘12334‘ -e "use novel;select count(*) from $n;";done >test.txt
[root@git-server ~]# cat test11.txt fpagentcount(*)1fpagentpropcount(*)0fpagentsessioncount(*)0fpchatsettingcount(*)51fpdispatchercount(*)1fpdispatcherpropcount(*)0fpofflinesettingcount(*)0fpqueuecount(*)1fpqueueagentcount(*)1fpqueuegroupcount(*)0