Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 2 down vote accepted

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                  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 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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.