Follow the steps below if you have forgotten your mysql root password and wish to reset it.
1. Create a text file with the following information in it.
UPDATE mysql.user SET Password=PASSWORD(’NEW_PASSWORD’) WHERE User=’root’;
FLUSH PRIVILEGES;
Replace “NEW_PASSWORD” with your desired mysql password. Save the file to /etc/mysql-pass-reset
2. Stop MySQL
/etc/init.d/mysqld stop
3. Start mysqld_safe with the –init-file option like so:
mysqld_safe –init-file=/etc/mysql-pass-reset &
This will start mysql and execute the query in the text file you created.
4. Now stop and start mysql back up normally without the –init-file option.
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
Don’t forget to delete the “mysql-pass-reset” file when you are done!
rm /etc/mysql-pass-reset