PostgreSQL 10 Administration Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it…

First, create a file named pg_service.conf with the following content:

[dbservice1] 
host=postgres1
port=5432
dbname=postgres

You can then copy it to either /etc/pg_service.conf or another agreed central location. You can then set the PGSYSCONFDIR environment variable to that directory location.

Alternatively, you can copy it to ~/.pg_service.conf. If you want to use a different name, set PGSERVICEFILE. Either way, you can then specify a connection string like the following:

service=dbservice1 user=sriggs

The service can also be set using an environment variable named PGSERVICE.