我完全无法访问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>"
如果我使用sudo
运行它:
$ sudo psql
Password for user root:
psql: error: could not connect to server: FATAL: password authentication failed for user "root"
如果我与postgres
用户一起运行:
$ sudo -u postgres psql
Password for user postgres:
psql: error: could not connect to server: FATAL: password authentication failed for user "postgres"
在我的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
有人有什么建议吗?