在列出不存在的角色名称时,如何在PostgreSQL(psql)中重置密码?
我已经安装了很长时间的PostgreSQL,但目前只是在学习它。
如果我运行psql
在命令提示符中发生了什么事
c:\ users \ vandarsq> psql 用户Vanda Rashq的密码:
由于我忘记了vanda rashq
角色的密码,但我记得postgres
角色,i run psql -u Postgres
。
我还尝试了使用从pg_roles中选择rolname
命令和收益:
我试图关注此教程>但它返回错误:角色“ Vanda Rashq”不存在
我的问题是,“ Vanda Rashq”角色实际上仍然存在吗?如果是,则如何重置(更改)密码,以防我忘记密码?如果没有,如何将psql
postgres 角色
注释:注释时, 如何更改默认角色目录,但是当我尝试运行psql
时,它仍然会问用户Vanda Rashq
的密码
I have installed PostgreSQL for a long time but just currently learning it.
Here is what happened if I run psql
in the command prompt
C:\Users\VandaRsq>psql Password for user Vanda Rashq:
Since I forgot the password for the Vanda Rashq
role but I remember for the postgres
role, I run psql -U postgres
.
I tried to list the role by using du
command and the result is this:
I also tried using SELECT rolname FROM pg_roles
command and yield:
I have tried to follow this tutorial and do ALTER USER "Vanda Rashq" WITH PASSWORD 'new_password';
but it returns ERROR: role "Vanda Rashq" does not exist
My question is, does the "Vanda Rashq" role actually still exist? If yes, how to reset (change) the password in case I forgot the password? If not, how to change the default role when running psql
to postgres
role
Notes: I have tried to uninstall the PostgreSQL and remove all of the directories but when I try to run psql
, it still ask Password for user Vanda Rashq
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您要寻找的用户在
psql
中调用\ du
后未列出,则数据库中不存在用户。顺便说一句,您还可以使用选择来检索有关数据库用户的信息:
select * select * from pg_catalog.pg_user;
edit:
@jjanes of @jjanes指出,您会挑战基于密码的挑战在
user
pg_hba.conf 中的配置上。对于身份验证方法
peer
,它被说明:If the user you're looking for is not listed after calling
\du
inpsql
then the user does not exist in the database.Btw, you could also use a select to retrieve information about database users:
select * from pg_catalog.pg_user;
EDIT:
Like @jjanes pointed out you get challenged for a password based on the
USER
configuration in yourpg_hba.conf
(see docs).For authentication method
peer
it is stated: