ALTER USER

On this page Carat arrow pointing down
Warning:
CockroachDB v19.1 is no longer supported as of October 30, 2020. For more details, refer to the Release Support Policy.

The ALTER USER statement can be used to add or change a user's password.

Tip:

You can also use the cockroach user command 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

ALTER USER IF EXISTS name WITH PASSWORD password

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

icon/buttons/copy
> ALTER USER carl WITH PASSWORD 'ilov3beefjerky';
ALTER USER 1

Change password using an identifier

The following statement changes the password to ilov3beefjerky, as above:

icon/buttons/copy
> 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:

icon/buttons/copy
> ALTER USER carl WITH PASSWORD ThereIsNoTomorrow;

To preserve case in a password specified using identifier syntax, use double quotes:

icon/buttons/copy
> ALTER USER carl WITH PASSWORD "ThereIsNoTomorrow";

See also


Yes No
On this page

Yes No