【问题标题】:PostgreSQL authentification with passwordPostgreSQL 密码认证
【发布时间】:2013-11-06 07:19:44
【问题描述】:

我使用 PostgreSQL 9.2 并有命令:

psql -h localhost -U testdb -d postgis

此命令可以在没有密码的情况下连接数据库。我想输入密码。

我的pg_hba.cconf 是:

local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

【问题讨论】:

标签: database linux postgresql authentication


【解决方案1】:

无密码访问需要相应配置多个authentication methods 之一。这些相关答案中的更多详细信息:
pgadmin gives me the error: no password supplied
Run batch file with psql command without password

特别是,localhost 不是第二个pg_hba.conf 文件中的“本地连接”。由于您连接的是-h localhost,因此只有pg_hba.conf 文件中以host 开头的行适用,因此需要输入密码。

其余说明:

  • You did not reload 因为配置文件已更改。

  • 您没有显示正确的(或完整的)pg_hba.conf(或无意中连接到错误的数据库集群。端口 5432?),实际上有一条与 peerident 身份验证的行位于其他 host 行之前。

  • 您的安装有一个.pgpass file,它授予您运行命令的系统用户访问权限。详情请参考the second linked answer

最后一个似乎最有可能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-16
    • 2018-04-21
    • 2021-12-23
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    相关资源
    最近更新 更多