ALTER USER

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

ALTERUSERIFEXISTSnameWITHPASSWORDpassword

Parameters

ParameterDescription
nameThe name of the user whose password you want to create or add.
passwordLet 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

  1. > ALTER USER carl WITH PASSWORD 'ilov3beefjerky';
  1. ALTER USER 1

Change password using an identifier

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

  1. > 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:

  1. > ALTER USER carl WITH PASSWORD ThereIsNoTomorrow;

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

  1. > ALTER USER carl WITH PASSWORD "ThereIsNoTomorrow";

See also

Was this page helpful?
YesNo