【发布时间】:2019-09-18 07:10:57
【问题描述】:
我们正在尝试通过 COPY 命令使用 postgresql 的 psql 将数据从一个 Amazon RDS 数据库迁移到 Amazon Aurora Serverless 数据库。当我从 EC2 实例运行该脚本时,它运行良好,但我需要手动为 rdswizard 和 postgres 每次迭代提供密码。我只想在psql 命令中提供密码。如何在psql命令中不每次都手动输入密码?
allSites=(3 5 9 11 29 30 31 32 33 34 37 38 39 40 41 45 46 47 48)
for i in "${allSites[@]}"
do
psql \
-X \
-U rdswizard \
-h my_rds_host_url_goes_here \
-d wizard \
-c "\\copy (select site_id,name,phone from client_${i} where date(create_date) > '2019-09-11' LIMIT 100) to stdout" \
| \
psql \
-X \
-U postgres \
-h my_aurora_serverless_host_url_goes_here \
-d wizard \
-c "\\copy client_${i}(site_id,name,phone) from stdin"
done
我的两个数据库主机都在远程服务器上而不是在本地机器上
【问题讨论】:
标签: bash postgresql amazon-rds psql aws-aurora-serverless