On this page
Warning:
CockroachDB v19.2 is no longer supported as of May 12, 2021. For more details, refer to the Release Support Policy.
The ALTER USER
statement can be used to add or change a user's password.
Considerations
- Password creation and alteration is supported only in secure clusters for non-
root
users.
Required privileges
The user must have the INSERT
and UPDATE
privileges on the system.users
table.
Synopsis
Parameters
Parameter | Description |
---|---|
name |
The name of the user whose password you want to create or add. |
password |
Let the user authenticate their access to a secure cluster using this new password. Passwords should be entered as string literal. For compatibility with PostgreSQL, a password can also be entered as an identifier, although this is discouraged. |
Examples
Change password using a string literal
> ALTER USER carl WITH PASSWORD 'ilov3beefjerky';
ALTER USER 1
Change password using an identifier
The following statement changes the password to ilov3beefjerky
, as above:
> ALTER USER carl WITH PASSWORD ilov3beefjerky;
This is equivalent to the example in the previous section because the password contains only lowercase characters.
In contrast, the following statement changes the password to thereisnotomorrow
, even though the password in the syntax contains capitals, because identifiers are normalized automatically:
> ALTER USER carl WITH PASSWORD ThereIsNoTomorrow;
To preserve case in a password specified using identifier syntax, use double quotes:
> ALTER USER carl WITH PASSWORD "ThereIsNoTomorrow";