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.
Switch mysql service to safe mode using below command
Step 3 :
Change database to mysql
Database changed
Step 4 :
Enter New Mysql root password by below command
Step 5 :
Update the new password
Stop the mysql service
Step 1:
First stop the mysql service.
[root@linuxstorages ~]# /etc/init.d/mysqld stopStep 2:
Stopping mysqld: [ OK ]
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;Exit the mysql safe mode connection
Query OK, 0 rows affected (0.05 sec)
mysql> quitStep 6 :
Bye
[2]+ Exit 1 mysqld_safe --skip-grant-tables
Stop the mysql service
[root@linuxstorages ~]# /etc/init.d/mysqld stopNow login via new root password as we updated
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
[root@linuxstorages ~]# mysql -u root -p
0 comments :
Post a Comment