Postgresql – Can’t read config files from pgAdminIII on local Kubuntu machine

configurationpostgresql-9.4

My database starts fine, I can connect to it from pgAdmin and run queries. However when I go to Tools->Server Configuration->postgresql.conf I get an error. The error states

could not stat file "postgresql.conf": No such file or directory
CONTEXT: SQL function "pg_file_length" statement 1.
STATEMENT: SELECT pg_file_read('postgresql.conf', 0, pg_file_length('postgresql.conf'))

I tried to run that statement as its own query and came up with no such function. I googled around and found that I need adminpack so I installed that. Now when I run the same query I get `could not open file "postgresql.conf" for reading: No such file or directory.

The file does indeed exist at /etc/postgresql/9.4/main/ so I put the full path in the command and it tells me that absolute paths aren't allowed. I made a symlink in my data directory /var/lib/postgresql/9.4/main of the postgresql.conf file. Doing that allows me to open postgresql.conf from pgamin. However, when I save the file I notice that I get a new postgresql.conf in my data directory and that it renames the symlink to postgresql.conf.bak which means when I have conflicting postgresql.conf files between the /etc/…/main and the /var/…/main directories.

One thought is to move all the .conf files from the /etc/ directory to the /var/ and then put symlinks in the /etc/ but I figure I should just ask rather than screw around.

Best Answer

pg_hba and postgresql.conf should stay under

/etc/postgresql/[pg_version]/main/

then you should link them to /var/lib.. with:

#:ln -s /etc/postgresql/[pg_version]/main/pg_hba.conf
/var/lib/postgresql/[pg_version]/main/pg_hba.conf