Root Password is a vital part on mysql database. Root user has privilege to manage all mysql resources. This user can make/modify database user account, manipulates database setting, etc. So, root password is a very important. But, how does it account lost?.
This article will explain how to recovery your mysql root password with a simple way. It's easy way to reset lost mysql root password.
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
First, you must login to server as root then do this steps:
1) Stop mysql running process.
# /etc/init.d/mysqld stop
2) Run mysql daemon with skip grant table.
# mysqld_safe --skip-grant-tables
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.61 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>
3) Login to mysql as root without password.
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.61 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>
4) Update mysql root 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("abcdef1234") where User='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> quit
Bye
5) Test new root password.
# mysql -u root -p
6) Finish