I have VM with ubuntu 18.04 server installed. I have installed postgres 10 from the repo.
Default installation. I made some connection count related changes in postgres.conf and connection security related changes in pg_hba.conf.
The install directories are all the default, including the data directory.
Server is running. I was able to create databases and access the same from java client.
But when I start psql from the same VM, it throws the following error.
Error: Invalid data directory
Just psql without any parameters also gives this error.
People have faced this error when they have tried to change the data directory which is not the case for me. Data directory is the default and it is owned by the postgres user.
ubuntu@ubuntu:~$ ls -l /var/lib/postgresql/10/
total 4
drwx------ 20 postgres postgres 4096 Jun 12 02:54 main
Any idea what could be the cause or where should I look for detailed error for psql client?
Best Answer
This happens when
pg_wrapper
is unable to figure out the data directory from the configuration.pg_wrapper
is the layer on top of postgres that can juggle between several live PostgreSQL instances on debian-based systems. As installed by thepostgresql-client
package,psql
is a link topg_wrapper
on such systems:Since you mention slightly modifying
postgresql.conf
, make sure you didn't change the permissions inside/etc/postgresql/
, includingpostgresql.conf
. That looks like the most plausible change that would immediately lead to the mentioned error. The next one would be that your changes are syntactically wrong, in a way thatpg_wrapper
would no longer be able to parse the file.