Skip to Content
Mastering PostgreSQL 12 - Third Edition
book

Mastering PostgreSQL 12 - Third Edition

by Hans-Jürgen Schönig
November 2019
Beginner to intermediate content levelBeginner to intermediate
470 pages
11h 59m
English
Packt Publishing
Content preview from Mastering PostgreSQL 12 - Third Edition

Making use of .pgpass

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering PostgreSQL 11 - Second Edition

Mastering PostgreSQL 11 - Second Edition

Hans-Jürgen Schönig
Learning PostgreSQL 11 - Third Edition

Learning PostgreSQL 11 - Third Edition

Christopher Travers, Andrey Volkov
PostgreSQL Server Programming - Second Edition

PostgreSQL Server Programming - Second Edition

Usama Dar, Hannu Krosing, Jim Mlodgenski, Kirk Roybal

Publisher Resources

ISBN: 9781838988821Supplemental Content