Re: Problem. createdb: could not connect to database postgres: could not connect to server: No such file or directory

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Jaisen N(dot)D(dot) <jaisuvyas(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem. createdb: could not connect to database postgres: could not connect to server: No such file or directory
Date: 2008-04-12 10:28:56
Message-ID: 0A43F1ED-8873-47B0-92BC-7E6CEFD65B6A@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Apr 12, 2008, at 7:11 AM, Jaisen N.D. wrote:
> localhost:/home/user# su - postgres
> postgres(at)localhost:~$ /usr/lib/postgresql/8.1/bin/initdb -D /var/
> lib/postgresql/data
> The files belonging to this database system will be owned by user
> "postgres".
> This user must also own the server process.
>
> The database cluster will be initialized with locale en_IN.
> The default database encoding has accordingly been set to UTF8.
>
> initdb: directory "/var/lib/postgresql/data" exists but is not empty
> If you want to create a new database system, either remove or empty
> the directory "/var/lib/postgresql/data" or run initdb
> with an argument other than "/var/lib/postgresql/data".

It says right here. You forgot to move your old data directory out of
the way. As it's from a Postgres 8.3 installation, Postgres 8.1 has
no way of knowing how to handle what's in there.

> postgres(at)localhost:~$ /usr/lib/postgresql/8.1/bin/pg_ctl -D /var/
> lib/postgresql/data -l logfile start
> postmaster starting
> postgres(at)localhost:~$ /usr/lib/postgresql/8.1/bin/createdb test
> createdb: could not connect to database postgres: 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"?
> postgres(at)localhost:~$
> -----------------------------------------------------
> Why it can't connect to server? How can I resolve it??

Because initialisation of the database (initdb) failed for the
aforementioned reason. There are probably some messages in your logs
about postgres failing to start or to operate on its data directory.
You can't just run a different major version of postgres on an
existing data directory.

You didn't tell what your goal is. Are you trying to downgrade an
existing database? If so, why would you want to do that?

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.

!DSPAM:737,48008eed927663372713408!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chad Showalter 2008-04-12 12:09:44 rule to update view that inserts into log
Previous Message Craig Ringer 2008-04-12 06:36:08 Re: Problem. createdb: could not connect to database postgres: could not connect to server: No such file or directory