There are number of ways to reset MySQL root password. I’m going to discuss one easy way here. This is basically for Windows installation of MySQL.
Here we go:
- Find the installation folder of MySQL
In my case, I used XAMPP. So I looked under xampp/ mysql/bin
- Edit the mysql configuration file, my.ini
Add skip-grant-tables just below [mysqld] , save the file and restart mysql
- After adding skip grant tables, all the privileges will be skipped and hence you’ll be able to login without any restriction.
- Now that all the privileges are off, you may change the root password, run the following query
UPDATE mysql.user SET Password=PASSWORD(‘yourpassword’) WHERE User=’root’
This will update root’s password to yourpassword. Now edit the mysql configuration file(my.ini) and remove skip-grant-tables, save the file and restart mysql service.
Congratulations you’ve successfully reset mysql root password, login with new password.