Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">16.9.0</button>

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/containers/current/docs/database-users/manage-users.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/containers/18.4.0/docs/database-users/manage-users.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/containers/18.3.0/docs/database-users/manage-users.md.txt)
- [18.1.0](https://docs.cloud.google.com/alloydb/omni/containers/18.1.0/docs/database-users/manage-users.md.txt)
- [17.10.0](https://docs.cloud.google.com/alloydb/omni/containers/17.10.0/docs/database-users/manage-users.md.txt)
- [17.9.0](https://docs.cloud.google.com/alloydb/omni/containers/17.9.0/docs/database-users/manage-users.md.txt)
- [17.7.0](https://docs.cloud.google.com/alloydb/omni/containers/17.7.0/docs/database-users/manage-users.md.txt)
- [17.5.0](https://docs.cloud.google.com/alloydb/omni/containers/17.5.0/docs/database-users/manage-users.md.txt)
- [16.14.0](https://docs.cloud.google.com/alloydb/omni/containers/16.14.0/docs/database-users/manage-users.md.txt)
- [16.13.0](https://docs.cloud.google.com/alloydb/omni/containers/16.13.0/docs/database-users/manage-users.md.txt)
- [16.11.0](https://docs.cloud.google.com/alloydb/omni/containers/16.11.0/docs/database-users/manage-users.md.txt)
- [16.9.0](https://docs.cloud.google.com/alloydb/omni/containers/16.9.0/docs/database-users/manage-users.md.txt)
- [16.8.0](https://docs.cloud.google.com/alloydb/omni/containers/16.8.0/docs/database-users/manage-users.md.txt)
- [16.3.0](https://docs.cloud.google.com/alloydb/omni/containers/16.3.0/docs/database-users/manage-users.md.txt)
- [15.18.0](https://docs.cloud.google.com/alloydb/omni/containers/15.18.0/docs/database-users/manage-users.md.txt)
- [15.17.0](https://docs.cloud.google.com/alloydb/omni/containers/15.17.0/docs/database-users/manage-users.md.txt)
- [15.15.0](https://docs.cloud.google.com/alloydb/omni/containers/15.15.0/docs/database-users/manage-users.md.txt)
- [15.13.0](https://docs.cloud.google.com/alloydb/omni/containers/15.13.0/docs/database-users/manage-users.md.txt)
- [15.12.0](https://docs.cloud.google.com/alloydb/omni/containers/15.12.0/docs/database-users/manage-users.md.txt)
- [15.7.1](https://docs.cloud.google.com/alloydb/omni/containers/15.7.1/docs/database-users/manage-users.md.txt)
- [15.7.0](https://docs.cloud.google.com/alloydb/omni/containers/15.7.0/docs/database-users/manage-users.md.txt)

<br />

This page describes how to create and manage AlloyDB Omni users and roles.

<br />

In addition to the default users and roles that come with PostgreSQL, you can create other PostgreSQL users or roles. These users have the same set of
privileges as the `postgres` user:
`CREATE ROLE`,
`CREATEDB`, and `LOGIN`. For more information about these
privileges, see [`CREATE ROLE`](https://www.postgresql.org/docs/16/sql-createrole.html).

You can change the privileges of any user by using the [`ALTER ROLE`](https://www.postgresql.org/docs/16/sql-alterrole.html) command. If you create a new user with the `psql` client, you can
choose to associate it with a different role, or assign different privileges.

## Before you begin

To use PostgreSQL commands to manage users on a cluster, you need the following:

- Access to the `psql` client
- Access to the `postgres` database user, or another user with the appropriate administrative privileges

## Create a database user

To create a database user that authenticates with the database directly using
a username and password---also known as *built-in authentication*--- use the following command:

```sql
  CREATE USER USERNAME WITH PASSWORD 'PASSWORD';
```

Replace the following:

- `USERNAME`: The user role's username.

- `PASSWORD`: The new password to assign to the
  user role.

For more information about how to create and define database users, see [`CREATE
USER`](https://www.postgresql.org/docs/16/sql-createuser.html).

After you create a user or a role, you can change its privileges by using the [`ALTER
ROLE`](https://www.postgresql.org/docs/16/sql-alterrole.html) command
in the `psql` client.

## Grant roles to a database user

To grant roles to a database user, use the following command:

```sql
GRANT ROLE to USERNAME;
```

Replace the following:

- `ROLE`: The role to grant to the database user.

- `PASSWORD`: The new password to assign to the
  user role.

To give a user superuser privileges, grant that user the `alloydbsuperuser` role.

## Change the password of a database user

To set a new password for a standard PostgreSQL database user, use the following command:

```sql
ALTER USER USERNAME WITH PASSWORD 'PASSWORD';
```

Replace the following:

- `USERNAME`: The database user's username.

- `PASSWORD`: The new password to assign to the
  user role.

For more information about changing a user's password, see [`ALTER ROLE`](https://www.postgresql.org/docs/16/sql-alterrole.html).

## Revoke a role from a database user

To revoke a previously granted privilege from one or more roles, or to revoke a
user's membership in a role, use the following command:

```sql
  REVOKE ROLE FROM USERNAME;
```

To remove a user's superuser privileges, revoke the `alloydbsuperuser` role
from that user.

## View a list of database users

To view a table of all database users and their group memberships, use the following command:

```sql
  \du
```

## Delete a database user

Before deleting a user, you must drop all the objects it owns or reassign their
ownership, and revoke any privileges the role has been granted on other objects.

To delete a user, use the following command:

```sql
  DROP ROLE USERNAME;
```