Monday, July 28, 2014

How to Recover Mysql Root Password - 6 Steps

12:30 PM

This post deals with recovering the Mysql root password. If you forget the root mysql password, following steps help us to recover it.





Step 1: 

First stop the mysql service.

[root@linuxstorages ~]# /etc/init.d/mysqld stop
Stopping mysqld:                                           [  OK  ]
Step 2:

Switch mysql service to safe mode using below command



[root@linuxstorages ~]# mysqld_safe --skip-grant-tables &
   

Login as root user

mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
 Step 3 : 

Change database to mysql


mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Step 4 :

 Enter New Mysql root password by below command

mysql> update user set password=PASSWORD("NewPassword") where User='root';
Query OK, 3 rows affected (0.09 sec)Rows matched: 3  Changed: 3  Warnings: 0

Step 5 :

Update the new password

mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
Exit the mysql safe mode connection

mysql> quit
Bye
[2]+  Exit 1                  mysqld_safe --skip-grant-tables
Step 6 :

Stop the mysql service

[root@linuxstorages ~]# /etc/init.d/mysqld stop
140723 06:52:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld:                                           [  OK  ]
[1]+  Done                    mysqld_safe --skip-grant-tables
Now login via new root password as we updated



         [root@linuxstorages ~]#  mysql -u root -p

Written by

0 comments :

Post a Comment

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism