Pgpass

From PostgreSQL wiki

Revision as of 17:55, 16 October 2013 by Bbrooks (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Most access to the database, including the psql program, goes through the libpq library. This library includes a feature where if you specify a file called .pgpass (or the file referenced by PGPASSFILE) you can put the password needed to connect as a user in there. This allows automating routine administration tasks through mechanisms like cron.

The format of the .pgpass file is the following:

hostname:port:database:username:password 

the character '*' can match any value in any of the fields (except password)

n.b.: if the environment variable PGPASSWORD is set, then the ~/.pgpass file is not read

Example PGPASSFILE value for a path with spaces on Windows 7 64-bit:

set PGPASSFILE=C:\Program Files\someapp\pgpass.conf

Note that the environment variable value must not use " (double quotes).

Personal tools