Re: Howto tell pg_ctl to use a non-default directory for config files

From: arif rahman <arif0729(at)icloud(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Grimm <trashcan(at)ellael(dot)org>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Howto tell pg_ctl to use a non-default directory for config files
Date: 2026-06-04 20:20:15
Message-ID: 26DCB02F-6703-4C46-92CB-B15C02CC66EF@icloud.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

In PostgreSQL, the configuration files do not have to live inside the data directory. You can place them elsewhere and tell PostgreSQL where to find them.

# Set postgresql.conf outside the data directory
hba_file = '/usr/local/etc/postgres/pg_hba.conf’

# pg_hba.conf
For Patroni or pg_auto_failover
Use scram-sha-256

local all all peer
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256

Then start
postgres -D /var/db/postgres/data \
-c config_file=/usr/local/etc/postgres/postgresql.conf

> On Jun 4, 2026, at 1:02 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Michael Grimm <trashcan(at)ellael(dot)org> writes:
>> Question:
>> Is there a way to tell PostgreSQL to look for config files in e.g. /usr/local/etc/postgres, where normally all config files reside in FreeBSD? [2]
>
> Typically you would say "pg_ctl -D /usr/local/etc/postgres" to point
> it at the config file. Then you would need the config file to include
> data_directory and perhaps other settings pointing to wherever the
> actual data files are. See
>
> https://www.postgresql.org/docs/current/runtime-config-file-locations.html
>
> regards, tom lane
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Jorge Daniel 2026-06-04 21:13:45 Pg14 replication issue , recovery stucks in a random file without advancing while streaming from primary
Previous Message Tom Lane 2026-06-04 20:15:11 Re: Howto tell pg_ctl to use a non-default directory for config files