Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am completely new to the game but need the following:

I Create a new role with login. Let's say: User1

I then create a Database 'User1Database' and set User1 as the owner.

User1 has no rights to do anything except for access.

Now when I connect using User1 it somehow has access to all databases. I then learned I neeed to write something in here.

User1 should have global access to User1Database and absolutely no access to anything else.

What lines do I need to add to my pg_hba file?

Currently it looks like this:

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
host    all             all             0.0.0.0/0     md5

Hope someone can write me the exact lines and explain them to me.

share|improve this question

2 Answers 2

If you want to allow everyone and their mother to have access use this. Though I would suggest limiting it to a private network if you can.

host    User1Database     User1   0.0.0.0/0         password
share|improve this answer

you will want to add two lines like:

local   User1Database     User1                        password
host    User1Database     User1   127.0.0.1/32         password

to allow local filesystem access and connecting to the service on localhost...

share|improve this answer
    
Thanks for that :) However, I need this user to have global access. Can you rewrite it for that? –  Mathias May 16 '10 at 19:47
    
Not always a good idea to allow global access –  aduljr May 16 '10 at 20:52
    
like aduljr posted and commented, opening up for global access is not a recommended route. if the user is going to be accessing from a few remote locations, or going to be using the db server as a backend for some website, you would want to put ip.add.re.ss/32 in place of 0.0.0.0/0 in his example, where ip.add.re.ss is the ip of the web-server/etc that needs to connect to your database server. usual access to a pgsql db is by shell or via local/remote webserver. just randomly connecting from unknown IPs is /pretty/ rare. –  cpbills May 17 '10 at 6:47

Your Answer

 
discard

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