Книга: 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.

Оглавление книги


Генерация: 1.012. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз