#!/bin/sh
HOST="127.0.0.1"
USER="dev"
PWD="DEVfunds@123"
DB="funds_balance"
HOST2="172.30.251.96"
USER2="dev"
PWD2="DEVfunds@123"
DB2="test"
SQL="select userId from balance where accountType='ECARD'"
RET=$(mysql -h$HOST -u$USER -p$PWD -D $DB -e "$SQL" |awk 'NR>1')
REP=$RET
for db in ${REP[@]}
do
echo ${db}
SQL2="insert into balance(userId,accountId,amount) values ('${db}','${db}_ecard','0.0000');"
RET2=$(mysql -h$HOST2 -u$USER2 -p$PWD2 -D $DB2 -e "$SQL2");
echo $SQL2
done
echo "[author:邓洋] 初始化balance数据完成!"
如果是导出多列 ,请参考我的另外一篇文章!!