0

I forgot passw for postgres DB so I have removed postgreSQL from system and I reinstalled it again with new passw. Now I can access postgres from SQL shell as postgres user by entering new passw and it works.

However when Im trying to open postgres from CMD, by executing psql postgres Im prompted to enter passw for user Pet. If I provide dbname and username in CMD psql postgres postgres then it doesnt attempt to log me in as Pet, it just accept my passw and log me in as postgres user. My question is why does it prompt me to log as Pet if I dont provide username? I havent set up Pet as user for Postgres DB, so it shouldnt even be asking for Pet passw which I have never set up, should it?

1 Answer 1

1

By doing:

psql postgres

you are telling psql to connect to the postgres database as the system user, in this case Pet. To accomplish what you want, do:

psql -d postgres -U postgres

where -d specifies the database you want to connect to and -U specified the database user you wish to connect as.

The details can be found in the docs here:

https://www.postgresql.org/docs/13/app-psql.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.