Monday, August 19

How to Setting, Changing and resetting mysql root password on Linux RHEL/CentOS


                  MySQL is most commonly used for Web applications and for  embedded  applications  and  has become a popular alternative to proprietary database systems because of its speed  and reliability. MySQL can run on LINUX, Windows and Mac OS.

i). Setting Mysql Root Password:
      Use Mysqladmin command to set new password as shown below. 
# mysqladmin -u root  password  newpassword

ii). Change Mysql Root Password:
          If you want to change (or update) a root password, then you need to use the following command:
# mysqladmin  -u  root  -p'oldpassword'   password 'newpass'
    For Example old password is "bsrtech" , now you can set the new password is " mahesh "
         # mysqladmin  -u  root  -p'bsrtech'   password 'mahesh'

iii). Resetting MySQL Root Password:
              If u have forgot mysql password in centos or redhat , how to change password steps given below..

Step1: Stop MySQL:

  #  service mysqld stop
Step2: Start MySQL in safe mode:

            #  mysqld_safe  --skip-grant-tables &
Step3: Log into MySQL as root:
           #  mysql -u root
Step4: Reset the password: 
 mysql>  update mysql.user set password=PASSWORD("your new password") where User='root';
mysql>  flush privileges; 
 mysql> exit;

Step5: Log out of MySQL and stop the Safe Mode:

#  service mysqld stop

Step6: Start MySQL in the normal mode:

#  service mysqld start

Step7: Log into MySQL with your new password:

#  mysql -u root -p
Enter password:


  1. Thx very much. It was very helpful =)

  2. Thank you! This was the best one that actually worked!!!


:: Linux - Legends ::