【问题标题】:How to migrate data between Postgres Servers which both need password? [duplicate]如何在都需要密码的 Postgres 服务器之间迁移数据? [复制]
【发布时间】:2021-10-19 02:48:07
【问题描述】:

我尝试使用命令在两台PG服务器之间迁移数据,但都需要密码:

pg_dump -h localhost -U 本地用户数据库名 | psql -h remotehost -U remoteuser 数据库名

然后我得到错误:

pg_dump: [archiver (db)] connection to database "database" failed: FATAL:  password authentication failed for user "postgres"

有什么办法可以解决这个问题吗?我不确定如何在命令中指定密码。

【问题讨论】:

  • 您可以将密码放入.pgpass
  • @a_horse_with_no_name 谢谢。

标签: postgresql


【解决方案1】:

使用password file 存储两个数据库的密码,然后PostgreSQL 客户端将能够连接到这两个数据库而无需提示输入密码。

密码文件如下所示:

localhost:5432:dbname:localuser:password1
remotehost:5432:dbname:remoteuser:password2

【讨论】:

    猜你喜欢
    • 2017-03-16
    • 1970-01-01
    • 2012-06-05
    • 2022-08-24
    • 1970-01-01
    • 2014-12-28
    • 2013-03-03
    • 1970-01-01
    • 2018-04-09
    相关资源
    最近更新 更多