Postgresql 不提示输入密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1335503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:49:17  来源:igfitidea点击:

Postgresql does not prompt for password

postgresqllogin

提问by Ash

I have a postgresql 8.3 db set up on linux box, together with a user postgres The pg_hba.conf reads

我在 linux box 上设置了一个 postgresql 8.3 db,还有一个用户 postgres pg_hba.conf 读取

local   all         postgres                          ident sameuser
local   all         all                               md5

so no trusted connections from local machine.

所以没有来自本地机器的可信连接。

Yet when connecting via commandline with psql, no password is asked and all users get all access to all databases.

然而,当通过命令行与 psql 连接时,不需要密码,所有用户都可以访问所有数据库。

I'm completely lost here..

我完全迷失在这里..

回答by

Are you sure you did restart or reload of PostgreSQL after pg_hba.conf change?

您确定在 pg_hba.conf 更改后重新启动或重新加载 PostgreSQL 吗?

If yes, type this command from postgres system account (shell):

如果是,请从 postgres 系统帐户(shell)键入以下命令:

psql -qAt -c "show hba_file" | xargs grep -v -E '^[[:space:]]*#'

If this will not help - show us output of the command.

如果这没有帮助 - 向我们展示命令的输出。

回答by Abdelhameed Mahmoud

You have to change both lines for IPv4 and IPv6 in pg_hba.conf

您必须在 pg_hba.conf 中更改 IPv4 和 IPv6 的两行

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

Server restart is needed.

需要重启服务器。

回答by Dirk Eddelbuettel

Try

尝试

 host   all   all   127.0.0.1/32        md5

instead.

反而。