postgresql psql fe_sendauth 未提供密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18152937/
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-10-21 01:03:43  来源:igfitidea点击:

psql fe_sendauth no password supplied

postgresql

提问by XWormX

I am new to this type of database and I try to connect to it through the command line specifying psql, and then entering the password as blank. I get the above error (in the title of this question).

我是这种类型的数据库的新手,我尝试通过指定 psql 的命令行连接到它,然后将密码输入为空白。我收到上述错误(在这个问题的标题中)。

I dont know what the default password.

我不知道默认密码是什么。

pg_hba file:

pg_hba 文件:

        IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    # IPv6 local connections:
    host    all             all             ::1/128                 trust
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    host    replication     DIMA        127.0.0.1/32            trust
    host    replication     DIMA        ::1/128                 trust

postgresql.config

postgresql.config

listen_addresses = '*'      # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost', '*' = all
                    # (change requires restart)
port = 5432             # (change requires restart)

I restart the server this way:

我以这种方式重新启动服务器:

C:\metasploit\postgresql\bin\pg_ctl -D "C:\metasploit\postgresql\myData" -l logfile start

All I want is to enter the database and change my password. And preferably to enter the PgAdmin-III (in GUI form)

我想要的只是进入数据库并更改我的密码。最好进入 PgAdmin-III(以 GUI 形式)

回答by Craig Ringer

If you were using trustauthentication (which you should only use for development, if then) you would not be prompted for a password by psql.

如果您正在使用trust身份验证(如果那样的话,您应该只将其用于开发)不会提示您输入密码psql

I'd say you didn't properly restart the server. Maybe use restartinstead of start?

我会说你没有正确重启服务器。也许用restart而不是start?

回答by Chris Travers

As Craig said, you probably didn't restart the server and you should use restart instead of start. (reload may work as well but not as sure on Windows)

正如克雷格所说,您可能没有重新启动服务器,您应该使用重新启动而不是启动。(重新加载也可以工作,但在 Windows 上不确定)

But that is not your problem. The key problem is almost certainly that you are not connecting to localhost and you have lines in your pg_hba.confthat are requiring passwords from other hosts.

但这不是你的问题。关键问题几乎可以肯定是您没有连接到本地主机,并且您的行中pg_hba.conf需要来自其他主机的密码。

Note if you connect to an external IP address, you will hit a different or more general rule.

请注意,如果您连接到外部 IP 地址,您将遇到不同或更一般的规则。

This error means, basically, that the pg_hba.conffile is set to password authentication but no password was supplied. If you cannot find the problem quickly, what IP address the connection is from should be in the postgresql log file.

这个错误基本上意味着pg_hba.conf文件被设置为密码认证,但没有提供密码。如果您不能快速找到问题,则连接来自哪个 IP 地址应该在 postgresql 日志文件中。

As for using trust, you should certainly change it back after changing your password. Ordinarily I would agree with Craig that one should not use trust authentication outside of development, but it is a legitimate approach to password resets of important users, and on Windows, this has to be done in ways supported well on the platform.

至于使用信任,你当然应该在更改密码后将其改回。通常我会同意 Craig 的观点,即不应在开发之外使用信任身份验证,但这是对重要用户进行密码重置的一种合法方法,而且在 Windows 上,这必须以平台支持的方式进行。

As a final note the question is how you are logging in. If you are going to set this, you should probably use psql -h 127.0.0.1 [dbname]to ensure Windows doesn't do something weird like try to connect using the machine name (and hence external IP).

最后一点,问题是您如何登录。如果您要设置它,您可能应该使用它psql -h 127.0.0.1 [dbname]来确保 Windows 不会做一些奇怪的事情,例如尝试使用机器名称(以及外部 IP)进行连接。