【问题标题】:How to connect to postgres with password given in .pgpass file?如何使用 .pgpass 文件中给出的密码连接到 postgres?
【发布时间】:2020-03-27 02:24:54
【问题描述】:

我的 .pgpass 文件位于 home/centos 目录中,权限为 0600。

10.43.11.123:5432:mydb:postgres:abcd@1234

(真实密码包含反斜杠字符。)

我已经尝试了link中给出的所有方法

没有任何作用。

我尝试了python can not use .pgpass while connecting to PostgreSQL 中提供的解决方案,但这也无济于事

每次报错:

psql: fe_sendauth: 未提供密码

我也试过了:

psql -h 10.43.11.123 -d mydb -U postgres

提示:

psql: FATAL: 用户“postgres”的密码验证失败 从文件“/home/centos/.pgpass”中检索到的密码

谁能帮忙?

【问题讨论】:

    标签: linux postgresql authentication psql


    【解决方案1】:

    根据the documentation:

    如果条目需要包含: 或\,请使用\ 转义此字符。

    由于您说密码包含反斜杠字符,因此解决方案是将反斜杠加倍。

    【讨论】:

      猜你喜欢
      • 2021-11-15
      • 2022-09-25
      • 2019-07-10
      • 2016-06-18
      • 2022-10-16
      • 2020-10-28
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      相关资源
      最近更新 更多