How To Set / Reset MySQL Password?

Changing passwords is quite a regular type of task for many webmasters and the same is also applicable to database administrators also. Here I would like to share the procedure of changing the password of MySQL. The root user is the admin of a MySQL account. Remember that it is different than login into the root account of a Linux hosting server.

If it’s your first time you are facing the question ‘How to change MySQL password?’ then the server will not require any password at all to connect as root. You will have to use mysqladmin command at shell prompt as shown following.

$ mysqladmin -u root password NEWPASSWORD

If you have your old password set and want to change it then you will have to use a different following command.

$ mysqladmin -u root -p oldpassword newpass
Enter password:

If you want to change the password of a normal user then again the command is different for that as follows.

$ mysqladmin -u user -p oldpassword newpass
$ mysqladmin –user=root –password=’old_password’ password ‘new_password’