• 修改数据库配置文件:vim /etc/my.cnf
[client]
user=username
password=password
  • 使用shell脚本统计表中的行数据:count.sh
#!/bin/bash
dbname=test
ip=192.168.1.100
for i in `mysql  -h$ip  -e "show tables from $dbname;" |  egrep -v "\||Tables_in_$dbname"`
do
        sleep 1
        count=`mysql  -h$ip -e "select count(1) from $dbname.$i" |grep -v "count"| awk -F "[ ]" "{print $1}"`
        echo  $i=$count >>/root/mysql.log        
done

统计mysql库中每张表的行数据

  • 使用awk取出大于100行的表
cat /root/mysql.log | awk -F '[=]' '{if($2>100){print $0}}'

相关文章:

  • 2021-11-30
  • 2021-05-30
  • 2021-08-14
  • 2022-12-23
  • 2021-11-20
  • 2021-05-20
  • 2022-02-08
  • 2021-05-16
猜你喜欢
  • 2021-10-26
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案