Thread: Can't login/createdb

Can't login/createdb

From
Joe Koenig
Date:
This is the stupidest thing ever and I'm sure I'm missing something
simple, but here goes:

I installed postgres and started it up as the post-installation-notes
file says to do. It starts up just fine, but I cannot log into the
interactive monitor, nor can I create any databases, even as root. I
checked the pg_hba.conf file and it is set to let all local users log
in. Whenver I type:

psql

to try and log in, I get FATAL 1:  Database "username" does not exist in
the system catalog. I've used pgsql before, but never installed it, so I
assume I missed something stupid, but looking back through the docs I'm
still missing it. Can anyone help me? Thanks,

Joe

Re: Can't login/createdb

From
Doug McNaught
Date:
Joe Koenig <joe@jwebmedia.com> writes:

> I installed postgres and started it up as the post-installation-notes
> file says to do. It starts up just fine, but I cannot log into the
> interactive monitor, nor can I create any databases, even as root. I
> checked the pg_hba.conf file and it is set to let all local users log
> in. Whenver I type:
>
> psql
>
> to try and log in, I get FATAL 1:  Database "username" does not exist in
> the system catalog. I've used pgsql before, but never installed it, so I
> assume I missed something stupid, but looking back through the docs I'm
> still missing it. Can anyone help me? Thanks,

What you need to do:

1) Become user 'postgres' (or whatever the postmaster is running
   as)--this is the Postgres superuser.
2) Run "createuser" to create other allowed users.
3) Run "createdb" to create other databases.
4) Use "psql <dbname>" to connect to them.

Make sense?

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863

Re: Can't login/createdb

From
Dado Feigenblatt
Date:
by default psql conects to a database by the same name as the user.
So you have two problems here.

There's no user or database named joe (assuming that's your username on
your system)
On a fresh install there's only one user, postgres, and only one
database to login, template1.

psql -U postgres template1

This should.
Once connected, create an user for you (and any other you might need).
You might want ot give it permissions to create DB's and users.

dado.


On a brand new installation

Joe Koenig wrote:

>This is the stupidest thing ever and I'm sure I'm missing something
>simple, but here goes:
>
>I installed postgres and started it up as the post-installation-notes
>file says to do. It starts up just fine, but I cannot log into the
>interactive monitor, nor can I create any databases, even as root. I
>checked the pg_hba.conf file and it is set to let all local users log
>in. Whenver I type:
>
>psql
>
>to try and log in, I get FATAL 1:  Database "username" does not exist in
>the system catalog. I've used pgsql before, but never installed it, so I
>assume I missed something stupid, but looking back through the docs I'm
>still missing it. Can anyone help me? Thanks,
>
>Joe
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>


--
Dado Feigenblatt                                 Wild Brain, Inc.
Technical Director                               (415) 216-2053
dado@wildbrain.com                               San Francisco, CA.




Re: Can't login/createdb

From
Joe Koenig
Date:
Alright, I've got that taken care of now. Thanks to everyone who
responded. Next dumb question - I need to be able to connect to postgres
from PHP - I know that I need to start it up with the '-i' option, but I
need to make sure it starts up with that option when the machine
reboots. I found the 010.pgsql.sh file and it says to edit
$PG_DATA/postgresql.conf - so I went to my data dir and uncommented the
line that said 'tcpip_socket = false' and changed it to true. When
trying to connect from PHP, I get an error stating:

Warning: Unable to connect to PostgreSQL server: pqReadData() -- backend
closed the channel unexpectedly. This probably means the backend
terminated abnormally before or while processing the request.

I'm sure that, once again, I'm missing something simple (Yes, I did stop
and restart the postmaster :) Thanks,

By the way, this is FreeBSD 4.3 with PHP 4.0.6

Joe

wsheldah@lexmark.com wrote:
>
> Use `su -` to be come root, then `su - postgres` to become the postgres
> superuser. Then you can connect to the database via psql and add other users,
> and give yourself database superuser permissions if you want. Assuming you're on
> a unix-like system of course.
>
> It's always good to mention your OS including version, and the version of
> Postgres you're using. But this should get you going. Have fun!
>
> Wes Sheldahl
>
> Joe Koenig <joe%jwebmedia.com@interlock.lexmark.com> on 12/05/2001 03:30:06 PM
>
> Please respond to joe%jwebmedia.com@interlock.lexmark.com
>
> To:   pgsql-general%postgresql.org@interlock.lexmark.com
> cc:    (bcc: Wesley Sheldahl/Lex/Lexmark)
> Subject:  [GENERAL] Can't login/createdb
>
> This is the stupidest thing ever and I'm sure I'm missing something
> simple, but here goes:
>
> I installed postgres and started it up as the post-installation-notes
> file says to do. It starts up just fine, but I cannot log into the
> interactive monitor, nor can I create any databases, even as root. I
> checked the pg_hba.conf file and it is set to let all local users log
> in. Whenver I type:
>
> psql
>
> to try and log in, I get FATAL 1:  Database "username" does not exist in
> the system catalog. I've used pgsql before, but never installed it, so I
> assume I missed something stupid, but looking back through the docs I'm
> still missing it. Can anyone help me? Thanks,
>
> Joe
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Can't login/createdb

From
Doug McNaught
Date:
Joe Koenig <joe@jwebmedia.com> writes:

> Alright, I've got that taken care of now. Thanks to everyone who
> responded. Next dumb question - I need to be able to connect to postgres
> from PHP - I know that I need to start it up with the '-i' option, but I
> need to make sure it starts up with that option when the machine
> reboots.

Are you sure?  If PHP uses libpq than it should be able to use Unix
domain sockets (on the same machine of course).

>                    I found the 010.pgsql.sh file and it says to edit
> $PG_DATA/postgresql.conf - so I went to my data dir and uncommented the
> line that said 'tcpip_socket = false' and changed it to true. When
> trying to connect from PHP, I get an error stating:
>
> Warning: Unable to connect to PostgreSQL server: pqReadData() -- backend
> closed the channel unexpectedly. This probably means the backend
> terminated abnormally before or while processing the request.

Well, this is either a backend crash (bad) or possibly an
authentication failure.  What do your logs say?  Are there any core
files in $PGDATA?

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863