OSETC TECH

Linux:How To Change MySQL User Password

For linux admin or DBA, it someone forgot normal user pasword, he must be ask for request to you to reset or change the orginal password. how do you change the user’s password? in this tutorial, you’ll see that how to change MySQL user password.

Change MySQL User Password

There are several ways to change MySQL user password, we will just talk one way as followss:

Using MySQL command to update or set new MySQL user password, issue the following command:

update <mysql user> set password=PASSWORD(<'new password'>) where user="username".

or

set password for '<username>'@'localhost' = PASSWORD('new password');

Example:

let’s change the password of MySQL user “mk” to “ddd”, issue the following command:

Firstly, login the mysql server using “mysql -u root -p“, enter the root password for authentication.

then, change to the correct database using “use mysql” command

Last,  we will try to change the MySQL user “mk” password :

SET PASSWORD FOR 'mk'@'localhost' = PASSWORD('ddd');

or

UPDATE mysql.user SET Password=PASSWORD('ddd') WHERE User='mk' AND Host='localhost';

Finally, you need to reload the privileges:

flush privileges;

you can also use mysqladmin tools to change MySQL user password.

If you forgot MySQL root password, then pls also see: how to reset forgotten MySQL Root Password

done…