[MySQL] Change the user password

Rex Chiang
Sep 11, 2021

Alter user password

1. Load mysql database.

USE mysql;

2. Execute ALTER command if MySQL version 5.7.6 or newer.

ALTER USER 'userName@localhost' IDENTIFIED BY 'NewPassword';

3. Execute ALTER command if MySQL version 5.7.5 or older.

SET PASSWORD FOR 'userName@localhost' = PASSWORD('NewPassword');

4. Reload the grant tables in the mysql database.

FLUSH PRIVILEGES;

--

--