How to Recover mysql root password
Sometimes we loose or forget the root password of mysql database. Following steps explain how to recover mysql root password by resetting it.
Step # 1: Stop mysql service
# /etc/init.d/mysqld stop Output: Stopping MySQL database server: mysqld.
Step # 2: Start mysqld daemon with skip-grant-tables option. This will start mysql without prompting for a password.
# mysqld_safe --skip-grant-tables & Output:  5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe: started
Step # 3: Connect to mysql server using mysql client and as root user.
# mysql -u root Output: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Step # 4: Now Reset Password
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('<new-password>') 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
Step # 5: Stop mysql service
Step # 6: Make sure that all mysql processes are stopped
ps -ef | grep -i mysql
Step # 7: Start the mysql
Step # 8: Now connect using user root and password
mysql -u root -p
That’s it! Please post your comments!
If you like this post and wish to receive more articles from us, please like our FB page: Button
Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.
For more details on our services, please drop us an E-mail at firstname.lastname@example.org