postgresql无法登录到postgres管理员用户,并且将auth设置为trust并没有帮助(MacOS)

时间:2019-01-28 17:24:37

标签: postgresql macos

我已经通过将postgres用户密码更改为null来加强了对本地Postgresql安装的访问权限,现在我根本无法访问postgresql。我已经按照以下步骤将pa_hba.conf固定为trust

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all             all                     trust
# IPv4 local connections:
host    all             all             0.0.0.0/32              trust
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.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

我已经用brew services restart postgres重新启动了postgres,但是那没有用...所以我只是重启了Mac ...也没有用。

我的身份验证尝试如下:

psql -U postgres
Password for user postgres:
psql: FATAL:  password authentication failed for user "postgres"

psql -U postgres
Password for user postgres:
psql: fe_sendauth: no password supplied

我确实注意到以下内容:

which postgres
/usr/local/bin/postgres

/usr/local/bin/postgres不存在,我要修改的配置位于/usr/local/var/postgres/pg_hba.conf

先决条件信息:

postgres --version
postgres (PostgreSQL) 11.1

操作系统:MacOS

1 个答案:

答案 0 :(得分:1)

所以,我知道了...

首先,我不得不通过下述顺序的完全清除我的PG的系统:http://hzchirs-blog.logdown.com/posts/142678-how-completely-uninstall-postgresql-9x-on-mac-osx

接下来,我遇到了以下错误:

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432”?:

无法通过任何可用的在线方法解决以上错误,这使我不得不删除最初不存在的postmaster.pid文件...

上述解决方案是将127.0.0.1 localhost.localdomain localhost节添加到我的主机文件中,结果发现,我丢失了我非常关心的几乎所有主机文件条目(我将其归咎于安全性)团队推送愚蠢的更新)...

在那之后,我终于能够运行pg_ctl -D /usr/local/var/postgres -l logfile start和启动PSQL,然后登录并设置我的用户/ DBS与psql postgres

在解决上述问题之前,我看到could not translate host name "localhost", service "5432" to address: nodename nor servname provided, or not known

Buuut,现在人们正在工作!