Reset Forgotten MySQL Root Password

Want to support HowtoForge? Become a subscriber!
Submitted by cmdln (Contact Author) (Forums) on Tue, 2008-02-26 12:28. :: MySQL

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.

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by (not registered) on Sat, 2014-08-02 21:45.




Submitted by Leopoldo Vettor (not registered) on Fri, 2014-08-01 01:01.
Even in 2014!!!! =)
Submitted by Binita (not registered) on Fri, 2013-12-06 09:14.
Thank you. Works perfectly on  MYSQL - 5.6.14.
Submitted by Lance (not registered) on Mon, 2013-12-02 14:03.
Thank you!! It worked a treat for me.
Submitted by John (not registered) on Wed, 2013-07-10 09:44.
kool Article password recovered thanks :) 

however also took help from below URL

Submitted by natalia (not registered) on Mon, 2013-04-01 09:40.
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
Submitted by Anonymous (not registered) on Tue, 2012-07-17 14:15.
also can by

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

Submitted by Anonymous (not registered) on Fri, 2012-12-14 00:32.
You have to enter the current password to use mysqladmin so this does NOT work.
Submitted by Erik Cayré (not registered) on Wed, 2012-05-23 10:01.
Thank you:)
Submitted by Anonymous (not registered) on Wed, 2012-05-02 19:59.
It worked for me too.. :-)
Submitted by mindchaser (not registered) on Fri, 2011-06-10 22:40.
worked for me on Ubuntu 10.10.  Thanks!
Submitted by santangs (not registered) on Sat, 2011-04-09 11:53.
Thank 4 tutor, mysistem worked now..
Submitted by hyperion (not registered) on Tue, 2010-10-12 21:08.

tested this on my dev server. smoked the database.

obviously mis-written or not tested by the author.

Submitted by mindstalker (not registered) on Thu, 2014-07-17 14:40.

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)

Submitted by Anonymous (not registered) on Tue, 2012-11-13 22:52.
You should never ever tried post on production server!! D
Submitted by Anonymous (not registered) on Fri, 2012-11-30 17:45.
They said dev server, dev != production to me. Works perfectly for me though so I wonder what they did wrong.
Submitted by mlokhandwala (not registered) on Sun, 2010-07-25 05:30.

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

mysqld --skip-grant-tables

to start the deamon without applying priviliges

Submitted by Anonymous (not registered) on Fri, 2010-10-08 08:40.
i like to use password recovery software
Submitted by Anonymous (not registered) on Wed, 2009-02-11 14:35.
Submitted by Gee Thanks for ... (not registered) on Wed, 2009-02-11 06:32.

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!

Submitted by Anonymous (not registered) on Mon, 2009-02-09 02:32.

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

.. someone either edit or delete this tutorial

Submitted by Anonymous (not registered) on Tue, 2008-12-16 22:07.
where user='root' must be added... Otherwise, it worked without a problem. thanx.
Submitted by Anonymous (not registered) on Mon, 2008-12-08 20:38.
This howto is wrong and dangerous! please add where user='root' at the end of the update statement!
Submitted by cnemo (not registered) on Tue, 2008-09-23 03:39.
Submitted by mahy (registered user) on Tue, 2008-04-15 06:50.

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. 


Submitted by Kalin Mandaliev (not registered) on Fri, 2012-07-27 12:49.
You are incredible :) nice how to !!!!
Submitted by Rana (not registered) on Thu, 2012-08-09 08:13.

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