Postgresql Postgres请求忘记密码(MacOS)

Postgresql Postgres请求忘记密码(MacOS),postgresql,Postgresql,我完全无法访问postgres中的任何内容,因为它要求为默认的postgres用户以及我的mac用户名提供密码。我也没有密码,而且在postgres的情况下,我甚至不明白为什么有一个密码,因为它不应该有密码 在浏览了关于该主题的许多其他答案后: 如果我运行psql: $ psql Password for user <MY_USERNAME>: psql: error: could not connect to server: FATAL: password authenticat

我完全无法访问postgres中的任何内容,因为它要求为默认的
postgres
用户以及我的mac用户名提供密码。我也没有密码,而且在
postgres
的情况下,我甚至不明白为什么有一个密码,因为它不应该有密码

在浏览了关于该主题的许多其他答案后:

如果我运行
psql

$ psql
Password for user <MY_USERNAME>:
psql: error: could not connect to server: FATAL:  password authentication failed for user "<MY_USERNAME>"
如果我使用
postgres
user运行它:

$ sudo -u postgres psql
Password for user postgres:
psql: error: could not connect to server: FATAL:  password authentication failed for user "postgres"
此外,在my
pg_hba.conf
中,所有方法都设置为信任,还尝试更改为
ident
md5

根据@jjanes的建议,我搜索了其他
pg_hba.conf
文件,结果如下:

/usr/local/var/postgres.old/pg_hba.conf
/usr/local/var/postgres/pg_hba.conf
/usr/local/var/postgresql@10/pg_hba.conf
/Library/PostgreSQL/12/data/pg_hba.conf
最后一个是空的(并且是只读的),其他三个都是这样的:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

有人有什么建议吗?

听起来你在找错误的pg_hba.conf文件。如果该方法真的被设置为信任或标识,您将不会收到该错误消息。@jjanes,所以它位于/usr/local/var/postgres中,但我还有一些postgres文件存储在/usr/local/cillar/postgresql/12.1中,这是自制的。我真的不太了解这些东西,有没有可能这就是问题所在?我也检查了那个目录,有一个pg_hba.conf.samlple文件,但就是它*.sample文件不是那个。postgresql.conf可能为要使用的HBA文件设置了一个不同于pg_HBA.conf的名称,但不太可能。你能使用Linux的
find
命令之类的工具在你的系统上搜索任何pg_hba.conf吗?我正要登机,但我会在另一边检查,看看我的系统上是否还有其他pg_hba.conf航班。谢谢
# TYPE  DATABASE        USER            ADDRESS                 METHOD

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