Re: running postgres

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: running postgres
Date: 2009-02-05 12:16:33
Message-ID: 20090205121633.GC3008@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 05, 2009 at 12:05:31PM +0530, Kusuma Pabba wrote:
> how can i create a user in test or template
> when i give create user
> it is asking for create role , how should i create role?

Users are associated with the "cluster" and not with any specific
database. I tend to add users by directly entering the SQL, but, as
others have noted, there's a program called "createuser" that you can
use instead. Only a few users can normally create new users (or "roles"
as they have recently been changed to) and you can see who by typing
\du into psql and looking for the "Create role" column. Normally only
the database owner (i.e. the "postgres" user) can create new users by
default, which is probably where you got the "su postgres" command from.

Once you've logged in with somebody whose capable of creating users, you
need to type something like:

CREATE USER furble;
GRANT CONNECT ON DATABASE test TO furble;

This will create the user "furble" and allow them to connect to the
"test" database. I believe it's generally preferable to use groups to
control permission and add users to groups rather than granting them
specific rights. But use cases vary. The manual pages for these things
are:

http://www.postgresql.org/docs/current/static/user-manag.html
http://www.postgresql.org/docs/current/static/sql-createrole.html
http://www.postgresql.org/docs/current/static/sql-grant.html
http://www.postgresql.org/docs/current/static/app-createuser.html

You will probably need to think about authentication, at which point the
following section will help:

http://www.postgresql.org/docs/current/static/client-authentication.html

--
Sam http://samason.me.uk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Filip Rembiałkowski 2009-02-05 15:18:31 Re: Array, bytea and large objects
Previous Message Harald Fuchs 2009-02-05 12:14:37 Re: Array, bytea and large objects