Search code examples
postgresqldefaultpsql

How to change the default username a postgresql db is connecting to?


I've seen posts that describe how to set postgresql server to connect to your own user but I could not find any posts that describe how to make psql connect to the default postgres user instead by default. In my case, right after installation when I open up psql, it connects to the username with the name same as my windows user instead of the postgres user that I want it to connect to.


Solution

  • As documented in the manual you can define an environment variable PGUSER which is used instead of your Windows user as the default user for all Postgres command line tools.