'How to reset password in postgresql (psql) for particular role in case when I list the role name it is not exist?
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
Solution 1:[1]
If the user you're looking for is not listed after calling \du
in psql
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:
Obtain the client's operating system user name from the operating system and check if it matches the requested database user name.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |