Store PostgreSQL password for psql

Store PostgreSQL password for psql
28. Feb 2012
1 minute read

I was asked today how to use store an password for use with psql. I’ve done this before several times but could not remember how. So I tried to look it up with man psql. There was a referer to .pgpass but no syntax. The pgpass is part of libpq. So this is a reminder to myself:

.pgpass format

hostname:port:database:username:password

To quote the Documentation: “Each of the first four fields may be a literal value, or *, which matches anything.”



Back to posts