Reset Forgotten MySQL Root Password

To reset mysql root’s password first we need to stop the server , then start with these commands:

mysqld_safe --skip-grant-tables

Now we can log in to the server with : mysql -u root , then use mysql and finaly we can change the password with these commands:

update user set password=PASSWORD('newpass') where user='root';
flush privileges;
exit;

Now just start mysql again! That’s it! 🙂