November 2019
Beginner to intermediate
470 pages
11h 59m
English
A very common way to store login information is via the use of .pgpass files. The idea is simple: put a file called .pgpass into your home directory and put your login information there. The format is simple:
hostname:port:database:username:password
An example would be the following:
192.168.0.45:5432:mydb:xy:abc
PostgreSQL offers some nice additional functionality, where most fields can contain *. Here is an example:
*:*:*:xy:abc
The * character implies that on every host, on every port, for every database, the user called xy will use abc as the password. To make PostgreSQL use the .pgpass file, make sure that the right file permissions are in place:
chmod 0600 ~/.pgpass
Furthermore, .pgpass can also be used on ...