1

(Debian 8)

My .pgpass file is at my home folder (admin)

I and using the right format as indicated in the documentation

hostname:port:database:username:password

The same fields I put there work well when put explicitly into the psql command line. (of course I have to enter the password manually).

However, running psql by itself gives our an error:

psql: FATAL: role "admin" does not exist

Note that my postgres username is NOT "admin", which is my debian username.

What am I doing wrong? my goal is to get access to psql without having to use an elaborate command line including host/port/username/database

5

psql defaults to using your current unix username when connecting, unless you specify something different.

If you want a different default you can set the PGUSER environment variable.

See https://stackoverflow.com/q/17632278/398670

.pgpass is what psql looks up to find out the password for a given host, username, port, etc combo. It doesn't specify what connection to use, only the password to use for a given connection.

You can use env vars, a sevice file, and/or shell aliases to specify connection defaults.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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