Howto recover mysql root password on Centos Redhat RHEL Fedora

Howto recover mysql root password on Centos Redhat RHEL Fedora

1. Stop mysql service

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

2.  Start mysql deamon on safe mode

[root@localhost ~]# mysqld_safe –skip-grant-tables &
[1] 7855
[root@localhost ~]# 130307 09:35:31 mysqld_safe Logging to ‘/var/log/mysqld.log’ .
130307 09:35:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/ mysql[root@localhost ~]#

3.  Now we can login to mysql without password and update new password for root

[root@localhost ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.30 MySQL Community Server (GPL) by RemiCopyright (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.

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
mysql> update user set password=PASSWORD(“ithelpblogpass”) where User=’root’;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@localhost ~]#

4. Restart mysql and now you can login with new password

[root@localhost ~]# /etc/init.d/mysqld restart
130307 09:49:01 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[1]+ Done mysqld_safe –skip-grant-tables
[root@localhost ~]#
[root@localhost ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.30 MySQL Community Server (GPL) by RemiCopyright (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.

 

That’s all. Thanks for using IThelpblog.com.

 

 

Tags:  

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>