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

From: "Jaisen N(dot)D(dot)" <jaisuvyas(at)gmail(dot)com>
To: "Sam Morris" <sam(at)robots(dot)org(dot)uk>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Re: Problem:- createdb: could not connect to database postgres: could not connect to server: No such file or directory
Date: 2008-04-19 04:29:25
Message-ID: 7db916da0804182129y1621adbek81ed5e7f71da9197@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi., Sorry for my late reply, I wasn't on desk for last few days. My goal is
to set up a spatial database, with postgresql 8.1. I removed the postgresql
installation using apt-get --purge remove. and removed the
var/lib/postgresql/data directory. And then reinstalled it again. The result
I got is here:-
--------------------------
localhost:/home/user# apt-get install postgresql-8.1
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
postgresql-client-8.1
The following NEW packages will be installed:
postgresql-8.1 postgresql-client-8.1
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/5711kB of archives.
After unpacking 15.1MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Selecting previously deselected package postgresql-client-8.1.
(Reading database ... 197573 files and directories currently installed.)
Unpacking postgresql-client-8.1 (from
.../postgresql-client-8.1_8.1.11-0etch1_i3
86.deb) ...
Selecting previously deselected package postgresql-8.1.
Unpacking postgresql-8.1 (from .../postgresql-8.1_8.1.11-0etch1_i386.deb)
...
Setting up postgresql-client-8.1 (8.1.11-0etch1) ...

Setting up postgresql-8.1 (8.1.11-0etch1) ...
Creating new cluster (configuration: /etc/postgresql/8.1/main, data:
/var/lib/po stgresql/8.1/main)...
Moving configuration file /var/lib/postgresql/8.1/main/postgresql.conf to
/etc/p ostgresql/8.1/main...
Moving configuration file /var/lib/postgresql/8.1/main/pg_hba.conf to
/etc/postg resql/8.1/main...
Moving configuration file /var/lib/postgresql/8.1/main/pg_ident.conf to
/etc/pos tgresql/8.1/main...
Warning: The socket directory for owners other than 'postgres'
defaults to /tmp. You might want to change the unix_socket_directory
parameter
in postgresql.conf to a more secure directory.
Configuring postgresql.conf to use port 5432...
Starting PostgreSQL 8.1 database server: main.

localhost:/home/user#
--------------------------------------
I created data folder again. But When I tried to create a test database, I
couldn't. Here is the steps I followed:-
--------------------------------------
localhost:/home/user# adduser postgres
adduser: The user `postgres' already exists.
localhost:/home/user# mkdir /var/lib/postgresql/data
localhost:/home/user# chown postgres /var/lib/postgresql/data
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.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating directory /var/lib/postgresql/data/global ... ok
creating directory /var/lib/postgresql/data/pg_xlog ... ok
creating directory /var/lib/postgresql/data/pg_xlog/archive_status ... ok
creating directory /var/lib/postgresql/data/pg_clog ... ok
creating directory /var/lib/postgresql/data/pg_subtrans ... ok
creating directory /var/lib/postgresql/data/pg_twophase ... ok
creating directory /var/lib/postgresql/data/pg_multixact/members ... ok
creating directory /var/lib/postgresql/data/pg_multixact/offsets ... ok
creating directory /var/lib/postgresql/data/base ... ok
creating directory /var/lib/postgresql/data/base/1 ... ok
creating directory /var/lib/postgresql/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /var/lib/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

/usr/lib/postgresql/8.1/bin/postmaster -D /var/lib/postgresql/data
or
/usr/lib/postgresql/8.1/bin/pg_ctl -D /var/lib/postgresql/data -l
logfile start

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:~$
--------------------------------------
Where is the problem??
The logfile in home folder of postgres user is as follows:-
--------------------------------------
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a
few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
----------------------------------------
How can I correct it??

On 12/04/2008, Sam Morris <sam(at)robots(dot)org(dot)uk> wrote:
>
> On Sat, 12 Apr 2008 10:57:28 +0530, Jaisen N.D. wrote:
>
> > Hai, I use Debian Etch. I have a problem with postgresql 8.1. I have
> > uninstalled the postgresql-8.3, which I was took from debian back ports,
> > removed its configuration files, and the user postgres also. Then
> > installed postgresql-8.1. But when I started to create a database, it
> > shows some message like this..
> > Here is the output I got:-
> > -----------------------------------------------------
> > 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". 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??
>
>
> Debian uses /var/lib/postgresql/$pgversion/$clustername to store its
> clusters. It doesn't use /var/lib/postgresql/data as far as I know. So I
> suggest you move it aside and try again.
>
> You should really be using the pg_createcluster command however. Then you
> will have a cluster correctly located so that Debian's initscripts will
> start and stop the server at startup and shutdown.
>
> You can also use pg_lsclusters to see what clusters (if any) were left
> behind by your previous install of 8.3.
>
> Finally, I suggest you read /usr/share/doc/postgresql-common/
> README.Debian.gz for an overview of how the Debian packages of postgresql
> integrate with the rest of the system.
>
> --
> Sam Morris
> http://robots.org.uk/
>
> PGP key id 1024D/5EA01078
> 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078
>
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>

--
(`'·.¸(`'·.¸ ¸.·'´) ¸.·'´)
«´¨`·*Jaisen.*..´¨`»
(¸.·'´(¸.·'´ `'·.¸)`'·.¸)
¸.·´
( `·.¸
`·.¸ )
¸.·)´
(.·´
( `v´ )
`v´

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Graham Leggett 2008-04-19 12:58:35 Could not create a tablespace - permission denied
Previous Message Medi Montaseri 2008-04-18 18:52:57 Dev Process