How to Reset MySQL root Password

I don’t know how many times I have forgotten passwords, you would think I would learn to keep them safe somewhere. Well, if you are forgetful like me, here is how to reset the root password of mysql.

#/etc/init.d/mysql stop
#mysqld_safe –skip-grant-tables &

#mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD(“newpass”) where  User=’root’;
mysql> flush privileges;
mysql> quit

#/etc/init.d/mysql stop

#/etc/init.d/mysql start
#mysql -u root -p

Now you can login as root with your new password.

Permanent link to this article: https://daherlabs.mywire.org/wordpress/?p=7

Leave a Reply

Your email address will not be published.