Reset Forgotten MySQL Root Password 

Have you ever forgotten the root password on one of your MySQL servers? No? Well maybe I’m not as perfect as you. This is a quick h00tow (how to) reset your MySQL root password. It does require root access on your server. If you have forgotten that password wait for another article. Original article posted on reset mysql root password.

First things first. Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.

mysqld_safe --skip-grant-tables

You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

mysql --user=root mysql

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

Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.

Share this page:

31 Comment(s)

Add comment



The following statement wil reset passwords for ALL USERS, not just root. This will do the desired thing:

UPDATE user SET Password=PASSWORD('newpwd') WHERE User='root';

Check out for more advice. 


From: Kalin Mandaliev

You are incredible :) nice how to !!!!

From: Rana

It worked for me,Thanks a lot. Really worth reading.I do found simile article. at hope this help.


From: cnemo
From: Anonymous

This howto is wrong and dangerous! please add where user='root' at the end of the update statement!

From: Anonymous

where user='root' must be added... Otherwise, it worked without a problem. thanx.

From: Anonymous

I did this this other day before I saw the comments.  My database is hosed.  Thankfully it was my small system but now I need to figure out how to fix it.  Thanks. 

 Next time please test this on your own server before posting! We appreciate the effort but can't afford this kind of help!

From: Anonymous

Thank you for fucking up my entire database and all it's users!

.. someone either edit or delete this tutorial

From: mlokhandwala

I tried this technique and it worked perfectly. Just that I used

mysqld --skip-grant-tables

to start the deamon without applying priviliges

From: Anonymous

i like to use password recovery software

From: hyperion

tested this on my dev server. smoked the database.

obviously mis-written or not tested by the author.

From: Anonymous

You should never ever tried post on production server!! D

From: Anonymous

They said dev server, dev != production to me. Works perfectly for me though so I wonder what they did wrong.

From: mindstalker

If you start getting a disconnection error after following the root reset steps do this.

sudo mysql_upgrade -u root -pnewpassword

(need to put -p then newpassword with no space as it won't always properly prompt you for password, this will fix the database better than then repair database functionality)

From: santangs

Thank 4 tutor, mysistem worked now..

From: mindchaser

worked for me on Ubuntu 10.10.  Thanks!

From: Anonymous

It worked for me too.. :-)

From: Erik Cayré

Thank you:)

From: Anonymous

also can by

  $ /usr/bin/mysqladmin -u root password 'new-password'

From: Anonymous

You have to enter the current password to use mysqladmin so this does NOT work.

From: natalia

On ubuntu/debian, u can use the debian-sys-maint user to recover it. no need to start mysql in safe mode. you can read the full instructions here: Recover MySQL root password

From: John

kool Article password recovered thanks :) 

however also took help from below URL

From: Lance

Thank you!! It worked a treat for me.

From: Binita

Thank you. Works perfectly on  MYSQL - 5.6.14.

From: Leopoldo Vettor

Even in 2014!!!! =)

From: [email protected]





From: joost

I can login yes but now all my databases are empty...

From: momox

nice gan.

it's work

From: Georgi Georgiev

Totaly not working.

From: till

Used it several time and it always worked.