Книга: Fedora™ Unleashed, 2008 edition
Creating Database Users in PostgreSQL
Creating Database Users in PostgreSQL
To create a database user, you use su
to become the user postgres
from the Linux root account. You can then use the PostgreSQL createuser
command to quickly create a user who is allowed to access databases or create new database users, like this:
$ createuser phudson
Shall the new user be allowed to create databases? (y/n) y
Shall the new user be allowed to create more new users? (y/n) y
CREATE USER
In this example, the new user named phudson
is created and allowed to create new data bases and database users (you should carefully consider who is allowed to create new databases or additional users).
You can also use the PostgreSQL command-line client to create a new user by typing psql
along with name of the database and then use the CREATE USER
command to create a new user. Here is an example:
CREATE USER foobar ;
CAUTION
PostgreSQL allows you to omit the with password
portion of the statement. However, doing so causes the user to be created with no password. This is a security hole, so you should always use the with password
option when creating users.
NOTE
When you are finished working in the psql
command-line client, you can type q
to get out of it and return to the shell prompt.
- users
- Creating Users
- Deleting Users
- Configuring PostgreSQL
- Initializing the Data Directory in PostgreSQL
- Creating a Database in PostgreSQL
- Deleting Database Users in PostgreSQL
- Granting and Revoking Privileges in PostgreSQL
- 5.3.4. Mobile Users
- Creating child domains within zones
- Deleting a Photo
- Database Workbench