postgres-9.4 claims data directory is missing, when it isn't

8.5k Views Asked by At

I'm having trouble starting postgresql-9.4 on Centos 6.

I can't run initdb because the data directory already exists.

But I can't start the service because the data directory is missing!

[centos@dave-gbp ~]$ sudo service postgresql-9.4 start

/var/lib/pgsql/9.4/data is missing. Use "service postgresql-9.4 initdb" to initialize the cluster first.
                                                       [FAILED]
[centos@dave-gbp ~]$ sudo service postgresql-9.4 initdb
Initializing database: mkdir: cannot create directory `/var/lib/pgsql/9.4/data/pg_log': File exists
                                                       [FAILED]

Any idea how I can get past this problem?

1

There are 1 best solutions below

0
On

The solution is very easy for initdb.

  1. Use cd /var/lib/pgsql/9.4/data In Which Two files 1.pg_log, 2.postgresql.conf

  2. remove both using rm -rf .

  3. Then exit from all directory.

  4. use command "/usr/pgsql-9.4/bin/postgresql94-setup initdb" for initialze db