How to Change, set or change MySQL root Password

Once you installed MySQL, you might need to set the MySQL root password to protect your DB. Actually how to do that?

Just type the following command on your terminal

[root@techkaki] # mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use following command

 [root@techkaki] # mysqladmin -u root -p 'oldpassword' password newpass

Eg:

[root@techkaki] # mysqladmin -u root -p 'abcdef' password '123456'