1

I'm new to PostgreSQL database, some things is solved other as in MySQL. I have question how to simplest add separated user from other objects in database.

I want create user, should have permission to template1. He must can create databases and can login. I want her databases will be visible only to her. I want her not list/look/have any permissions to other users databases created in this way.

What is a simple solution to get this?

Thanks for help

1 Answer 1

2

The easiest way to do this is require that the user has the same name as the database, and configure pg_hba.conf so that all users are limited to the sameuser database. For instance, something like:

# TYPE  DATABASE        USER            CIDR-ADDRESS            METHOD
host    sameuser        all             0.0.0.0/0               md5

You'll need to add this in addition to listing any administrative accounts that have access to all the databases separately. If you know the IP address users will be connecting from, change 0.0.0.0/0 to match. If users are connecting via the local socket rather than over TCPIP, change TYPE to local and remove the address column. The md5 method means that passwords are required. You'll also need to have a row for the template1 database that gives all users access.

As for not allowing them to see other user's databases at all, I'm not sure what you can do about it since they're listed in the pg_catalog schema, and listed by psql -l

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .