Change mysql root password using MySQL sql command

You can directly update password using the following method to update or change password for user vivek:

1) Login to mysql server, type the following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user mehrdust, enter:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='mehrdust';

4) Finally, reload the privileges:

mysql> flush privileges;
mysql> quit

You may also like