
This article shows, how you can recover MySQL root password in Linux. Remember root password for login into the linux machine is different from root password which is used to access mysql.
If you have forgotten MySQL Database Server root password, you can easily recover it using following steps:
1. Stop the MySQL server process.
/etc/init.d/mysql stop
2. Start the
MySQL (mysqld) server/daemon process with the --skip-grant-tables option
so that it will not prompt for password.
mysqld_safe --skip-grant-tables &
Output:
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
3. Connect to mysql server as the 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>
4. Setup new mysql root account password.
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
5. Restart the MySQL server.
/etc/init.d/mysql restart
6. Login using new root password of mysql:
mysql -u root -p





