Creating Users

I l @ ve RuBoard

Database users are separate entities from regular operating system users. Depending on the particular application, it might be possible to have only one or two total database users. However, if multiple users need to connect to the database ”each with his or her own set of access rights ”it is desirable to create individual user accounts.

The easiest way to create users is to utilize the command-line utility createuser.

There are three main attributes to consider when creating new users:

  • Should they be able to create their own users? (Are they superusers?)

  • Should they be able to create their own databases?

  • Is authentication required? If so, what type and what password?

The actual act of creating users can take place either at the command line or in an interactive SQL session.

To create a user from the command line:

 >createuser web  >Shall the new user be allowed to create databases (y/n)? N  >Shall the new user be allowed to create users (y/n)? N 

Or, alternatively, from a SQL session:

 psql=>CREATE USER web NOCREATEDB NOCREATEUSER;  CREATE 

Creating a user from a SQL session enables some additional options that are not available from the command-line utility. For instance, passwords, group membership, and account expiration can all be set from this method.

Additionally, PostgreSQL enables users to be collected into logical groups for easier permission management. To create a group, the following command should be entered in a SQL session:

 CREATE GROUP webusers; 

Then users can be added or removed from the group, as follows :

 ALTER GROUP webusers ADD USER bill, mary, amy, jane;  ALTER GROUP webusers DROP USER mary; 
I l @ ve RuBoard


PostgreSQL Essential Reference
PostgreSQL Essential Reference
ISBN: 0735711216
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Barry Stinson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net