Skip to main content
SET PASSWORD changes the login password for users. The ALTER USER command can also be used to change a password. Tip
  • All users can reset their own password.
  • Only users with the user_admin role can change the password of other users.
  • Only the root user itself can change its password. For more information, see the priviege overview.

Syntax

The user_identity must match exactly the user_identity specified when creating a user by using CREATE USER. Otherwise, the user will be reported as non-existent. If user_identity is not specified, the password of the current user will be changed. The current user can be viewed through SHOW GRANTS. PASSWORD() inputs a plaintext password. If you directly input a string without using PASSWORD(), the string must be encrypted.

Examples

  1. Set the password for the current user.
  2. Set the password for a specified user.