问题描述:

I just followed this tutorial:

http://www.unixmen.com/postgresql-9-4-released-install-centos-7/

But I can't start my postgres sserver on my centOS 6.5 machine.

Here's the error:

[[email protected] ~]# service postgresql-9.4 initdb

Data directory is not empty!

[[email protected] ~]# service postgresql-9.4 start [FAILED]

Starting postgresql-9.4 service: [FAILED]

[[email protected] ~]# /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.

网友答案:

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.

网友答案:

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  ]*
相关阅读:
Top