The following are the steos to restore MySQL root password that is lost/forgotten.
Step 1: Stop MySQL daemon if it is currently running
Command to find the MySQL Pid and kill the MySQL process
ps –ax|grep mysql
kill -9 pid
Step 2: Run MySQL safe daemon with skipping grant tablesmysqld_safe --skip-grant-tables &Step 3: Login to MySQL as root with no password
mysql -u root mysql
UPDATE user SET password=PASSWORD("ualue=42") WHERE user="root";
FLUSH PRIVILEGES;
Step 5: Stop MySQL safe daemon
Command to find the MySQL safe daemon Pid and kill the MySQL process
ps –ax|grep
mysqld_safe
kill -9 pid
Step 6: Start MySQL/etc/init.d/mysql start
Step 7: Login into MySQL using root password
mysql -uroot -proot