If Yes, then no need to worry. Follow below easy steps to recover/crack your root password of MySQL database.
Step 1 : Stop MySQL service.
[root@afzalkhan ~]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
[root@afzalkhan ~]#
Step 2 : Start your MySQL database in safe mode. In this mode MySQL will not prompt for password.
[root@afzalkhan ~]# mysqld_safe --skip-grant-tables & [1] 14236 [root@afzalkhan ~]#Starting mysqld daemon with databases from /var/lib/mysql
Step 3 : Connect to your MySQL server. In safe mode MySQL will allow you to enter in any databases without any authentication.
[root@afzalkhan ~]# mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.0.95 Source distribution Copyright (c) 2000, 2011, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | afzalkhan | | OTRS | | ISP_DETAILS | | nagios | | mysql | | squid | | test | | Squid_Cache | +--------------------+ 10 rows in set (0.04 sec)
Step 4 : Select mysql database to make user level changes.
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 5 : Now you can update your root user password using below statement.
mysql> update user set password=PASSWORD("afzalkhantest") where User='root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql>
Step 6 : Execute FLUSH PRIVILEGES statement to tell the server to reload the grant tables.
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
Step 7 : Stop safe mode MySQL instance & start with normal mode.
[root@afzalkhan ~]# /etc/init.d/mysqld restart Stopping MySQL: [ OK ] starting MySQL: [ ok ] [root@afzalkhan ~]#
Step 8 : Now you should be able to connect your database using your new/cracked password
[root@afzalkhan ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.0.95 Source distribution Copyright (c) 2000, 2011, 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>