#!/bin/bash
echo "script start...."
Source='/data/dba/mysql8/bin/mysql -uadmin_dba -ppassword -h xxx '
Target='/data/dba/mysql8/bin/mysql -uadmin_dba -ppassword -h xxxxx '
# show databases 过滤出数据库名
echo $Source
dbs=`$Source -e "show databases \G" 2> /dev/null | grep "Database:"|grep -Ev " (awsdms_control|information_schema|mysql|sys|performance_schema)"| awk '{print $2}'`
echo $dbs
for db in $dbs
do
#echo $db;
# 过滤出有表名那一行
tables=`$Source -e "use $db;show tables \G" 2> /dev/null |grep "Tables_in_$db:"| awk '{print $2}'`
for table in $tables
do
# 过滤表名
num1=`$Source -e "select count(*) from $db.$table;" 2> /dev/null | grep [0-9]`
num2=`$Target -e "select count(*) from $db.$table;" 2> /dev/null | grep [0-9]`
echo $db.$table
if [ $num1 != $num2 ]
then
echo "error===============================error"
else
echo "source: $num1 target: $num2:::OK!!!"
fi
done
done
标签:grep,AWS,db,echo,Source,DMS,table,null,数据
From: https://www.cnblogs.com/tyhA-nobody/p/18382947