> [!WARNING]
>
> **Preview**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).
>
>
> For information about access to this release, see the [access
> request page](https://forms.gle/zxuHekMtV67Bw9Av9).

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

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/linux/current/docs/database-users/manage-users.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/linux/18.4.0/docs/database-users/manage-users.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/linux/18.3.0/docs/database-users/manage-users.md.txt)
- [18.1.1](https://docs.cloud.google.com/alloydb/omni/linux/18.1.1/docs/database-users/manage-users.md.txt)
- [18.1.0](https://docs.cloud.google.com/alloydb/omni/linux/18.1.0/docs/database-users/manage-users.md.txt)
- [17.5.0](https://docs.cloud.google.com/alloydb/omni/linux/17.5.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/18/sql-createrole.html).

You can change the privileges of any user by using the [`ALTER ROLE`](https://www.postgresql.org/docs/18/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/18/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/18/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/18/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;
```