Lost MySQL Password

If you have accidentally lost or mis-placed your MySQL password, you may reset it as follows:

1. Login to your server as root.

2. Stop MySQL: /etc/init.d/mysqld stop

3. Start MySQL in SafeMode: /usr/bin/mysqld_safe –skip-grant-tables &

4. Connect to MySQL: mysql -h localhost

5. Select the MySQL management database: use mysql;

6. Update the MySQL password: update user set password = password(‘newpassword’) where user = ‘root’ and host=’localhost’;

Note: Change newpassword to your new password.

7. Exit MySQL: quit

8. Stop MySQL in safe mode by running: ps -aux | grep mysql, stop the MySQL service using: kill <service ID>

9. Restart MySQL: /etc/init.d/mysqld start

10. Login to your MySQL instance using your new password: mysql -uroot -p, done!