最初我有
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
的新手,所以我不太了解这里发生了什么。有人可以帮我吗?
答案 0 :(得分:3)
如果未使用-U指定用户,则psql将默认为当前登录用户的用户名。在这种情况下,听起来该用户为hezhenghao。使用-U postgres以postgres用户身份登录。