I have setup separate config file and run
postgres=# ALTER DATABASE s2409 SET config_file = ‘E:/App/PostgreSQL/16/data/s2409/s2409_postgresql.conf’ ;
ERROR: parameter "config_file" cannot be changed without restarting the server.
The same error coming even after restart.
Can somebody suggest
I have done lot of restarts and included hba.conf & ident.conf files location in s2409_postgresql.conf
2
Answers
I believe this parameter is set at the time the PostgreSQL server starts, and it cannot be changed via SQL commands after the server has started.
There are several ways to start the server with the new config. You could try something like this for example:
You cannot have a unique config file per database. At least not the way you trying to do so. The config files you are trying to set are per-server files. Some of which have options that allow per-database settings. So you will need to write shared config files with settings for each database in them.
For instance,
pg_hba.conf
allows you to specify which databases a connection parameter applies to. eg.For your other per-database settings you will want to use a SQL script with
ALTER DATABASE
commands, and then run them against the postgres server once it is up and running. For example:These settings are then stored and set as the default setting when connecting to that database. For example:
These settings are not temporary, and will survive server restarts as they are stored in internal postgres databases.
NB. These settings will only take effect for new connections to a database and not any current connections.
You could, in theory, have unique config files per-database if you ran a distinct server per database. But I do not think that would be advisable to do so on the same host. For instance, if you knew a single server host could successfully manage
n
simultaneous connections, then each per-db server would have to limit its number of simultaneous connections ton/m
(wherem
is the number of database-servers). Otherwise the host might end up with more connections than it could handle and run out of RAM whilst working multiple, parallel queries.