Add, Modify and rescue mysql root password

Add, Modify and rescue mysql root password

        In the world of MySQL maintaining the root password is more precious. Every Linux and Database administrator should know how to add, modify and rescue forgot  root password.

Assign root password for Mysql :

Syntax:

#mysqladmin -u root password <new password>

 

Example :

#mysqladmin -u root password mysql@123

 

Modify root password of Mysql :

#mysqladmin -u root -p<old password> password <new password>

 

Example :

#mysqladmin -u root -pmysql@123 password mysql

 

If you forget your root password we can rescue password by using safemode

Stop the mysql and enter in to safe mode to change the mysql root password

 

Then you need to stop the mysql to exit from safe mode and again start mysql to boot it in normal mode. Then use mysql – p command to enter password and login in as root user.