[PostgreSQL]: Data directory is not empty! Error

[root@ip-10-0-0-228 ec2-user]# service postgresql initdb
Data directory is not empty! [FAILED]
[root@ip-10-0-0-228 ec2-user]#

Clean-up the data files & restart

[root@ip-10-0-0-228 ec2-user]# ll -lhtr /var/lib/pgsql9/data/
total 88K
-rw——- 1 postgres postgres 4 May 5 09:32 PG_VERSION
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_twophase
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_tblspc
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_stat_tmp
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_snapshots
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_serial
drwx—— 4 postgres postgres 4.0K May 5 09:32 pg_multixact
-rw——- 1 postgres postgres 20K May 5 09:32 postgresql.conf
-rw——- 1 postgres postgres 1.6K May 5 09:32 pg_ident.conf
-rw——- 1 postgres postgres 4.2K May 5 09:32 pg_hba.conf
drwx—— 3 postgres postgres 4.0K May 5 09:32 pg_xlog
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_subtrans
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_clog
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_notify
drwx—— 2 postgres postgres 4.0K May 5 09:32 global
drwx—— 5 postgres postgres 4.0K May 5 09:32 base
drwx—— 2 postgres postgres 4.0K May 5 09:32 pg_log
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]# rm -rf /var/lib/pgsql9/data/*
[root@ip-10-0-0-228 ec2-user]# ll -lhtr /var/lib/pgsql9/data/
total 0
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]# service postgresql initdb
Initializing database: [ OK ]
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]#
[root@ip-10-0-0-228 ec2-user]# ll -lhtr /var/lib/pgsql9/data/
total 88K
-rw——- 1 postgres postgres 4 May 7 10:42 PG_VERSION
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_twophase
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_tblspc
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_stat_tmp
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_snapshots
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_serial
drwx—— 4 postgres postgres 4.0K May 7 10:42 pg_multixact
-rw——- 1 postgres postgres 20K May 7 10:42 postgresql.conf
-rw——- 1 postgres postgres 1.6K May 7 10:42 pg_ident.conf
-rw——- 1 postgres postgres 4.2K May 7 10:42 pg_hba.conf
drwx—— 3 postgres postgres 4.0K May 7 10:42 pg_xlog
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_subtrans
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_clog
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_notify
drwx—— 2 postgres postgres 4.0K May 7 10:42 global
drwx—— 5 postgres postgres 4.0K May 7 10:42 base
drwx—— 2 postgres postgres 4.0K May 7 10:42 pg_log
[root@ip-10-0-0-228 ec2-user]#

  • Ask Question