删除用户后尝试访问 psql 但仍被要求输入已删除用户的密码

Trying to access psql after dropping a user but still got asked for entering password for the dropped user

最初我有

Role name  |                         Attributes                         | Member of 
------------+------------------------------------------------------------+-----------
 hezhenghao | Create DB                                                  | {}
 postgres   | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

然后我输入了

postgres=# REASSIGN OWNED BY hezhenghao to postgres
postgres-# ;
REASSIGN OWNED
postgres=# REASSIGN OWNED BY hezhenghao to postgres;                                                                                                 REASSIGN OWNED
postgres=# DROP OWNED BY hezhenghao;
DROP OWNED
postgres=# DROP USER hezhenghao;
DROP ROLE

现在只有一个用户

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

然而,当我在终端中输入 psql 时,我仍然被要求 Password for user hezhenghao: 然后我会得到 psql: FATAL: password authentication failed for user "hezhenghao"

我是 postgres 的新手,所以我不太明白这里发生了什么。有人可以帮我解决这个问题吗?

如果你没有用-U指定用户,那么psql将默认为当前登录用户的用户名。在这种情况下,听起来该用户是hezhenghao。使用-U postgres 以postgres 用户身份登录。