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

Shaii the new user be aiiowed to create databases? (y/n) y Shaii the new user be aiiowed 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 databases 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 psqi 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 ;

Was this article helpful?

0 0

Post a comment