Unix Technical Forum

Re: Problem. createdb: could not connect to database postgres:

This is a discussion on Re: Problem. createdb: could not connect to database postgres: within the Pgsql General forums, part of the PostgreSQL category; --> Jaisen N.D. wrote: > Hai, I use Debian Etch. I have a problem with postgresql 8.1. I have > ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 09:33 PM
Craig Ringer
 
Posts: n/a
Default Re: Problem. createdb: could not connect to database postgres:

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.

It sounds like you didn't remove the data directory,
/var/lib/postgresql/data .

By the way, if you want to remove all configuration etc along with a
package you should use apt-get --purge remove .
> 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".
>

initdb could not create a database cluster because there were files in
/var/lib/postgresql/data . You should rename the `data' directory to
something else or remove it. Removing it will destroy your database.

PostgreSQL 8.1 cannot read data from PostgreSQL 8.3 .

> postgres@localhost:~$ /usr/lib/postgresql/8.1/bin/pg_ctl -D
> /var/lib/postgresql/data -l logfile start
> postmaster starting
>

If you have a look at the postgresql logs you will see that postgresql
failed to start because it cannot read the data in the data directory;
it is for the wrong version of postgresql.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:49 PM
Martijn van Oosterhout
 
Posts: n/a
Default Re: Problem. createdb: could not connect to database postgres: could not connect to server: No such file or directory

On Sat, Apr 19, 2008 at 10:14:00AM +0530, Jaisen N.D. wrote:
> Hi., Sorry for my late reply, I wasn't on desk for last few days. My goalis
> 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:-


Why are you creating a database here:
> --------------------------------------
> 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


When it told you it already created one and it's already running.
> Creating new cluster (configuration: /etc/postgresql/8.1/main, data:
> /var/lib/po stgresql/8.1/main)...


<snip>

> Configuring postgresql.conf to use port 5432...
> Starting PostgreSQL 8.1 database server: main.


Delete directory just created and do this as root:

su - postgres
createuser <your username>
# Say you wanto to be superuser
createdb <database name>

> 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.


Use the server already running, instead of making another one.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFICboEIB7bNG8LQkwRAl5aAJ9O4glyJIgFx1Ano76YK9 NGlJg41gCghRrR
q+0fB7vGvzA0VpMy21sdtMI=
=8y/K
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:53 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com