[How to] Fix postgresql initdb data directory is not empty
Sometimes, it does happen that during the initialization of postgresql, we face the issue “data directory not empty”.
service postgresql initdb
Initialization of the database has to be done only once. If it is done, no need to do it again if the database start works. If not, you can fix this by deleting the directory /var/lib/pgsql/9.3/data. Once the directory is deleted, run service postgresql initdb again. This should initialize postgresql successfully.
Also, if service postgresql start fails, check for running instance of postgresql. Kill the postgresql process and run start again. This should fix this basic problem.