How to reset MySQL root password

To reset the MySQL root password, do the following:

USE DATABASE mysql;
SET PASSWORD FOR root@localhost=PASSWORD(‘yournewpassword’);
FLUSH PRIVILEGES;

And voila! You have changed your password.

PS: If you have a “problem” with beeing able to login to MySQL without using password (even when it is set in MySQL), try to edit or delete ~/my.cnf, since that holds information used to avoid the login promt.

Comments are closed.