file:mysql_rows.sh
运行:sh mysql_rows.sh 库名
脚本内容:
#!/bin/bash
user=...
pwd=...
ip=...
port=...
tb_name=`mysql -u $user -p$pwd -h$ip -P$port -e "select table_name from information_schema.tables where table_schema=$1" |awk ‘NR>1{print $1}‘`
>/date/$1.log
for name in $tb_name ;
do
tbl_count=`mysql -u $user -p$pwd -h$ip -P$port -e "select SQL_CALC_FOUND_ROWS 1 FROM $1.$name limit 1;SELECT found_rows() AS rowcount;"|awk ‘NR==4{print $1}‘`
echo "$name=$tbl_count" >>/date/$1.log
done
原文地址:https://www.cnblogs.com/dxian1028/p/12028306.html
时间: 2024-10-03 18:15:17