Re: How to change the default database for a user

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to change the default database for a user
Date: 2006-01-30 18:40:33
Message-ID: 878xsxa7a6.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Farber <alexander(dot)farber(at)gmail(dot)com> writes:

> but I do specify the database username:
>
> h754814:afarber {109} psql --help | grep -w user
> -U NAME database user name (default: "phpbb")
>
> h754814:afarber {110} psql -U punbb
> psql: FATAL: database "phpbb" does not exist
>
> And it wants to connect to a wrong database
> ("phpbb" instead of "punbb")

I was talking about the name of the database, not the user name in the
database. The former defaults to the same as your Unix username
(e.g. if I log in as 'doug' psql will try to connect me to a database
called 'doug' if I don't supply a database name). The PGDATABASE
environment variable overrides this. Are you sure it's not set?

Anyway, you should always supply the database name explicitly when you
connect--it's a lot safer.

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2006-01-30 18:53:49 Re: How to change the default database for a user
Previous Message Alexander Farber 2006-01-30 18:18:02 Re: How to change the default database for a user