Changes the password of a specified user.
Applicable engines and versions
Supported by all versions of LindormTable and LindormTSDB.
Syntax
ALTER USER [IF EXISTS] user_identifier SET PASSWORD = 'newpassword'
[WHERE OLDPASSWORD = 'oldpassword'];Parameters
ALTER USER can only change a user's password. Renaming a user is not supported.
user_identifier
The user whose password to change.
If the specified user does not exist and IF EXISTS is omitted, an error is returned. If IF EXISTS is included, the statement exits silently without returning an error.
SET PASSWORD
The new password. Must be of type VARCHAR.
WHERE OLDPASSWORD
The old password for verification. Must be of type VARCHAR.
In LindormTable, the WHERE OLDPASSWORD clause is required when a regular user changes their own password. It is not required when an administrator changes another user's password.
Examples
Administrator changes another user's password
Change the password of test_user to fda.@ using an administrator account:
ALTER USER IF EXISTS test_user SET PASSWORD = 'fda.@';Regular user changes their own password
Change the password of test_user to fda.@, with the old password t12a@Hi for verification:
ALTER USER test_user SET PASSWORD = 'fda.@' WHERE OLDPASSWORD = 't12a@Hi';