Changes a database user account.

Syntax

ALTER USER role_name IDENTIFIED BY password REPLACE prev_password

Description

You can use the ALTER USER… IDENTIFIED BY command to change the password if you are a role without the CREATEROLE privilege. An unauthorized role must include the REPLACE clause and previous password if PASSWORD_VERIFY_FUNCTION is not NULL in the configuration file. If a non-superuser uses the REPLACE clause, the server compares the provided password with the current password. If the passwords do not match, an error occurs.

Parameters

Parameter Description
role_name The name of the role whose password is to be changed.
password The new password of the role.
prev_password The previous password of the role.

Example

Change a user password:

ALTER USER john IDENTIFIED BY xyRP35z REPLACE 23PJ74a;