Friday, January 2, 2015

* No PostgreSQL clusters exist; see "man pg_createcluster"

psql error : * No PostgreSQL clusters exist; see "man pg_createcluster"

If you are trying to start postgresql server and you get this error.
Here is solution for you.

First you need to find the server version of your postgresql then you need to create cluster.

Suppose your server version is 9.3
pg_createcluster 9.3 main --start


psql: could not connect to server: No such file or directory

 psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


 If you are trying to open command prompt of postgresql using command psql and it gives above error it means your postgresql server is not started, you need to start it first.
service postgresql start
If it is giving error postgresql: unrecognized service, it means you are not starting correct service, you need to verify the correct name of the service.
Is it postgresql-9.3 or postgresql-9.4 or postgresql-8.4?

Now restart it after confirmation.
service postgresql-9.3 start
or
service postgresql-9.4 start
or
service postgresql-8.4 start

psql: FATAL: Ident authentication failed for user "root"

Postgresql error
psql: FATAL:  Ident authentication failed for user "root"

If you run command psql on terminal as root user and you get the error
psql: FATAL:  Ident authentication failed for user "root"
Here is solution for you. 

To resolve this error, Run these two commands on your terminal.
sudo -u postgres createuser root
It might give you this message
could not change directory to "/root"
Do not worry about it, when it asks
Shall the new role be a superuser? (y/n)

Enter y and press return key.

and the other command is
sudo -u postgres createdb root -O root
Now run command psql on terminal and you will log into postgresql command prompt as user root.

To check the list of postgresql databases, run command
\list

to quit the psql command prompt, run command
\q