Reset the MySQL password for the ‘root’ user

Reset the MySQL password for the ‘root’ user

If you have managed to forget the password for the root user on your MySQL installation you can easily change it by following this method.

  • Stop the mysql service
  • Find and open the my.ini file
  • Find the [wampmysqld](32bit) or [wampmysqld64](64bit) section in the ini file
  • Add this line directly after that section heading: skip-grant-tables
  • Restart the mysql service.
  • Open the MySQL console

The next steps will reset the password for the root user, if you need to reset the password for any other user you can use the same command by putting the appropriate username in the User field (WHERE User=’root’)

  • Enter the following 2 commands at the mysql> command prompt, each with a semi colon at the end of a line, and press ENTER after each line to issue the command to mysql.

 

UPDATE mysql.user SET authentication_string=PASSWORD(‘MyNewPass’) WHERE User=’root’;
ALTER USER ‘root’@’localhost’ PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;

  • Exit mysql (type  ‘quit’ at the mysql command promt)
  • Stop the mysql service
  • Find and open the my.ini file
  • Find the [wampmysqld](32bit) or [wampmysqld64](64bit) section in the ini file
  • Remove the skip-grant-tables parameter we added earlier.
  • Restart the mysql service.

You should now be able to login with phpmyadmin using the userid ‘root’ and the new password you have just set for that user.

Leave a Reply