1

I have just installed postgreSQL and have set up the user postgres and its password. In the psql Shell I am able to login as normal however I can't login in Windows Command Prompt. When I run the psql command it asks for Password for user username for which I don't know the password.

I have tried running dropuser username in the psql shell however this doesn't make a difference. When I use psql -u postgres to login and run postgres=# \du, the other role doesn't appear:

                                  List of roles
Role name |                         Attributes                         | 
Member 
of
----------+------------------------------------------------------------+-----------
postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
3
  • 2
    Pass the Postgres user you know the password for psql -U someuser ...
    – user1822
    Commented Jul 30, 2019 at 14:43
  • This allows me to login but will I have to do this every time rather than just psql
    – Matthew
    Commented Jul 31, 2019 at 8:38
  • I have edited my question
    – Matthew
    Commented Jul 31, 2019 at 8:43

1 Answer 1

0

If you want to override the default behaviour that chooses the current Windows' user name as the login for the database, you can define the environment variable PGUSER that contains the user you want to use by default.

Once that is defined and you type psql it assumes that user as the default.

Related: How do I specify a password to psql non-interactively?

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.