Reputation: 175
I just followed this tutorial:
http://www.unixmen.com/postgresql-9-4-released-install-centos-7/
But I can't start my postgres server on my centOS 6.5 machine.
Here's the error:
[root@vm5 ~]# service postgresql-9.4 initdb
Data directory is not empty!
[root@vm5 ~]# service postgresql-9.4 start [FAILED]
Starting postgresql-9.4 service: [FAILED]
[root@vm5 ~]# /etc/init.d/postgresql-9.4 start
Starting postgresql-9.4 service: [FAILED]
Before that tutorial I had already tried this one:
https://wiki.postgresql.org/wiki/YUM_Installation
I don't know what else to do.
Upvotes: 3
Views: 27142
Reputation: 858
I just had a similar problem. It was related to permissions. If you look at startup logs you should find error message.
cat /var/lib/pgsql/9.4/pgstartup.log
< 2018-05-03 22:15:35.896 EDT >FATAL: data directory "/var/lib/pgsql/9.4/data" has group or world access
< 2018-05-03 22:15:35.896 EDT >DETAIL: Permissions should be u=rwx (0700).
If it is related to permissions like in my case then run the following
chown -R postgres /var/lib/pgsql/9.4/data
chmod -R 700 /var/lib/pgsql/9.4/data
service postgresql-9.4 start
Upvotes: 2
Reputation: 523
It seems your postgres Data directory is not empty!
. So manually remove data
directory under lib/pgsql
like,
rm -rf /var/lib/pgsql/data
now initialize db. Yes, as @joop said, it would be better to take backup of data directory
mv /var/lib/pgsql/data /var/lib/pgsql/data.OLD;
mkdir /var/lib/pgsql/data;
chown postgres:postgres /var/lib/pgsql/data
If you are facing low disk memory in pgsql dir, you can move data
to some where, to do
cp -aRv /var/lib/pgsql/data to_dir/path
rm -rf /var/lib/pgsql/data/*
so here, I hope you won't face chown
problem.
Upvotes: 3
Reputation: 144
This has helped me to start the Postgresql database 9.5 after moved the data directory and installed with sudo. Please check below:
[hostname]# mv -f data data_BKP18072016
[hostname]# pwd
/var/lib/pgsql/9.5
[hostname]# sudo service postgresql-9.5 initdb
Initializing database: [ OK ]
[hostname]# sudo service postgresql-9.5 initdb
Starting postgresql-9.5 service: [ OK ]
[hostname]# sudo service postgresql-9.5 start
Starting postgresql-9.5 service: [ OK ]*
Upvotes: -1