代码之家  ›  专栏  ›  技术社区  ›  Cerin

如何允许postgres在本地连接上无密码提示登录?

  •  13
  • Cerin  · 技术社区  · 8 年前

    有几个类似的问题,例如 this this ,但没有修改的建议 pg_hba.conf 为我工作。然而,根据我对 pg_hba。形态 peer trust 选项。

    我试着运行一个命令,比如:

    sudo psql --user=postgres --no-password --command="blah;" -h 127.0.0.1
    

    :

    local   all             postgres                                trust
    

    我的命令失败,出现错误:

    psql: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL on
    FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL off
    

    如果我尝试这句话:

    local   all             postgres                                peer
    

    我的命令失败,出现了同样的错误。

    我该如何解决这个问题?

    1 回复  |  直到 8 年前
        1
  •  14
  •   a_horse_with_no_name    8 年前

    当您指定时 -h 127.0.0.1 那就是 local 将不匹配此连接。

    为指定主机名或端口 psql ,然后它将通过命名管道使用“本地”连接。

    或者,你可以 地方的 具有 host 然后添加 127.0.0.1 作为“信任”的(客户端)IP地址。