Archive for July, 2014

Reloading Postgres Configuration

Tuesday, July 15th, 2014

PostgreSQL.jpg

When you add a new user to a postgres database, you typically have to add them to the pg_hba.conf file and then tell postgres to reload it's configuration. There are a few ways to do this, and they are all pretty simple, but it bears writing them down for future reference.

First, adding a user is simple. Find the postgres directory - typically, all the files are there, and in that list will be a file called pg_hba.conf. The final few lines will need to look like:

  host all jim  0.0.0.0/0 trust

where here the user jim is considered to be trusted on all boxes he could come in on. This might be too liberal for you, but in most data centers, it's not an unreasonable assumption.

Then you need to tell postgres to reload the config. This can be done within the psql client:

  SELECT pg_reload_conf();

or from the shell, by the postgres user:

  /usr/local/bin/pg_ctl reload -D /var/pgsql

assuming the main postgres directory is /var/pgsql.