Reset mysql root password

Have you ever for­got­ten the root pass­word on one of your MySQL servers? No? Well maybe I’m not as per­fect as you. This is a quick h00tow (how to) reset your MySQL root pass­word. It does require root access on your server. If you have for­got­ten that pass­word wait for another arti­cle.


First things first. Log in as root and stop the mysql dae­mon. Now lets start up the mysql dae­mon and skip the grant tables which store the pass­words.

mysqld_safe --skip-grant-tables

You should see mysqld start up suc­cess­fully. If not, well you have big­ger issues. Now you should be able to con­nect to mysql with­out a pass­word.

mysql --user=root mysql
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit

Now kill your run­ning mysqld, then restart it nor­mally. You should be good to go. Try not to for­get your pass­word again.

11 Comments

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha