Home > *nix, Systems Administration > pg_service.conf Syntax

pg_service.conf Syntax

February 15th, 2010

I am setting up monitoring for my PostgreSQL database server, and ran across a cool way to get around specifying the username/password via the command-line every time the checks are run: pg_service.conf. Unfortunately, there is very little documentation on the config file. As best as I can figure out, if you are connecting to a remote host, your definitions should look as follows:

[service.name.here]
dbname=db.name.here
user=user.name.here
host=host.name.here
password=password.here

On a Gentoo Linux server with PostgreSQL 8.4 installed, this file will need to be placed at /etc/postgresql-8.4/pg_service.conf. Then, to reference it, simply export the PGSERVICE environment variable with the value of the name of the service in brackets.

*nix, Systems Administration ,

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.