How to change the default database for a user

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to change the default database for a user
Date: 2006-01-30 17:02:58
Message-ID: 943abd910601300902t33d29ca4oe0e087c3bec1a035@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I've created a user and a database both wrongly named "phpbb".
After that I have renamed both to "punbb" using "ALTER DATABASE"
and "ALTER USER". Now everything works fine, except I always
have to specify the database when connecting (both using psql or
the PQconnectdb() from my C-program):

h754814:afarber {103} psql -U punbb
psql: FATAL: database "phpbb" does not exist

h754814:afarber {104} psql -U punbb punbb
Welcome to psql 8.1.0, the PostgreSQL interactive terminal.
....
punbb-> \l
List of databases
Name | Owner | Encoding
-----------+-------------+-----------
postgres | _postgresql | SQL_ASCII
punbb | _postgresql | SQL_ASCII
template0 | _postgresql | SQL_ASCII
template1 | _postgresql | SQL_ASCII
(4 rows)

punbb-> \du
List of roles
Role name | Superuser | Create role | Create DB | Connections |
Member of
-------------+-----------+-------------+-----------+-------------+-----------
_postgresql | yes | yes | yes | no limit |
punbb | no | no | no | no limit |
(2 rows)

punbb-> select * from pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd |
passwd | valuntil | useconfig
-------------+----------+-------------+----------+-----------+----------+----------+-----------
_postgresql | 10 | t | t | t |
******** | |
punbb | 16384 | f | f | f |
******** | |
(2 rows)

How do I please set the database "punbb" to be the default
database for the user called "punbb"?

Regards
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2006-01-30 17:11:55 Re: How to change the default database for a user
Previous Message Kynn Jones 2006-01-30 17:00:02 How to define variables in psql scripts?