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 | {}
Best Answer
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?