# Set Account Password

__*TiDB account password settings*__

+ When CREATE USER creates a user:
  + Only users with CREATE USER privilege or mysql database privilege (INSERT privilege for create and UPDATE privilege for update) can set or modify passwords.
    + `CREATE USER 'test'@'localhost' IDENTIFIED BY 'mypass';`

+ To modify the password for an existing account:
  + `SET PASSWORD FOR 'test'@'localhost' = 'mypass';`
  + `ALTER USER 'test'@'localhost' IDENTIFIED BY 'mypass';`

-------------------------------------------------------------
TiDB stores the password in the mysql.user system database. Only users with CREATE USER privilege or mysql database privilege (INSERT privilege for create and UPDATE privilege for update) can set or modify passwords.

Specify the password with IDENTIFIED BY when creating a user in CREATE USER:

CREATE USER 'test'@'localhost' IDENTIFIED BY 'mypass';

modify the password for an existing account can be done with the SET PASSWORD FOR or ALTER USER statement:

SET PASSWORD FOR 'root'@'%' = 'xxx';
Or:
ALTER USER 'test'@'localhost' IDENTIFIED BY 'mypass';