Re: Why psql connection assumes default database name as the username - Mailing list pgsql-novice

From David G. Johnston
Subject Re: Why psql connection assumes default database name as the username
Date
Msg-id CAKFQuwZL-sahuhrL2cGtZfUHMOKj8cdND8KBrMW9xE5LUJ56OQ@mail.gmail.com
Whole thread Raw
In response to Re: Why psql connection assumes default database name as the username  (Neha Khatri <nehakhatri5@gmail.com>)
Responses Re: Why psql connection assumes default database name as the username  (Neha Khatri <nehakhatri5@gmail.com>)
List pgsql-novice
On Mon, Mar 27, 2017 at 5:58 PM, Neha Khatri <nehakhatri5@gmail.com> wrote:
Can a similar definition be applied in PostgreSQL for User and Database name mapping, i.e  if a database name is same as a user name then the access privileges for that datbase are guided by the properties defined for that user in view pg_roles?

​Nowhere in "pg_roles" does the name of a specific database appear - so no.

You defines roles.  You define databases.  You give roles CONNECT permissions on databases if you want them to be allowed to connect to said databases.  Of course, superusers can connect to anything.  That is, along as pg_hba.conf allows them to attempt a connection in the first place.

What I said above is wrong, though, if one leaves the default permissions of the implicit PUBLIC group in place.  By default all users are allowed to CONNECT to any database in the cluster - among other permissions.

So while creating a database of the same name of as a user "just works" it is working because of a default that can be changed.  The fact that the names match doesn't enter into it.


David J.


pgsql-novice by date:

Previous
From: Neha Khatri
Date:
Subject: Re: Why psql connection assumes default database name as the username
Next
From: Neha Khatri
Date:
Subject: Re: Why psql connection assumes default database name as the username