Forum Moderators: open

Message Too Old, No Replies

Beginner postgres question

         

gasell

6:25 pm on Sep 26, 2007 (gmt 0)

10+ Year Member



I added postgres installation to my xampp one on winxp. Then I created new login role x. When I try to create new database with php then I get an error that database x doesn't exist.
Do I need to have a database with the same name as user in order to create new database? It says the same when using psql from cmd. Or did I miss something else obvious for regular users?

Demaestro

6:43 pm on Sep 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



CREATE DATABASE name
[ [ WITH ] [ OWNER [=] dbowner ]
[ LOCATION [=] 'dbpath' ]
[ TEMPLATE [=] template ]----DEFAULT to use the default template (template1)
[ ENCODING [=] encoding ] ]

Did you pass all these variables in?

Demaestro

6:51 pm on Sep 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also

CREATE DATABASE cannot be executed inside a transaction block.

gasell

6:59 pm on Sep 26, 2007 (gmt 0)

10+ Year Member



Actually I had just "CREATE DATABASE name", but apparently I forgot to add default postgres database to pg_connect as described here: [postgresql.org...]

I probably should have been more specific about cmd issue. I use psql -U x, then it asks for my password and after providing that I get that message.

Demaestro

7:01 pm on Sep 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



nice.... so gasell you are good?

I am all about Postgres so any questions.... hit me up

I have it running on RedHat though

[edited by: Demaestro at 7:03 pm (utc) on Sep. 26, 2007]

gasell

8:31 pm on Sep 26, 2007 (gmt 0)

10+ Year Member



Yes, I got the php part working.

But I still had trouble using it from command line. It wanted the same x database there.
After creating empty db x, it let me use command line as user x, but it seems odd to require that.

Demaestro

3:23 pm on Sep 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ya... postgres is a little odd... it wants to to use a template when creating and if the user can't get the template weird stuff happens.