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:

38 Comment(s)

Add comment

Please register in our forum first to 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. 


By: Kalin Mandaliev

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

By: Rana

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


By: cnemo
By: Anonymous

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

By: Anonymous

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

By: 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!

By: Anonymous

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

.. someone either edit or delete this tutorial

By: mlokhandwala

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

mysqld --skip-grant-tables

to start the deamon without applying priviliges

By: Anonymous

i like to use password recovery software

By: hyperion

tested this on my dev server. smoked the database.

obviously mis-written or not tested by the author.

By: Anonymous

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

By: Anonymous

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

By: 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)

By: santangs

Thank 4 tutor, mysistem worked now..

By: mindchaser

worked for me on Ubuntu 10.10.  Thanks!

By: Anonymous

It worked for me too.. :-)

By: Erik Cayré

Thank you:)

By: Anonymous

also can by

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

By: Anonymous

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

By: 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

By: John

kool Article password recovered thanks :) 

however also took help from below URL

By: Lance

Thank you!! It worked a treat for me.

By: Binita

Thank you. Works perfectly on  MYSQL - 5.6.14.

By: Leopoldo Vettor

Even in 2014!!!! =)





By: joost

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

By: momox

nice gan.

it's work

By: Georgi Georgiev

Totaly not working.

By: till

Used it several time and it always worked. 

By: Muhammad Ahmad

This is a life saving guidance. Thanks it really helped me.

By: Roman

"In MySQL 5.7, the password field in mysql.user table field was removed, now the field name is 'authentication_string'."

now solution is:

mysqld_safe --skip-grant-tables

or  mysql.server restart --skip-grant-tables if you have OSX and brew mysql installation

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 authentication_string=PASSWORD('new-password') where user='root';flush privileges;exit;

By: Aldo


Terminal 1:

        sudo killall mysqld

        sudo mkdir /var/run/mysqld

        sudo chown mysql:mysql /var/run/mysqld

        sudo mysqld_safe --skip-grant-tables &


Terminal 2:

        mysql --user=root mysql

        UPDATE user SET authentication_string=PASSWORD('123456') WHERE user='root'; FLUSH PRIVILEGES;EXIT;

By: aditya sharma

HI! As you have mentioned first to log in as "root", But my case is I have forgotten the root user's password itsel. Please provide support

By: Natan Felles

Some errors on MySQL version 5.7.18:

The command mysqld_safe --skip-grant-table returns an error:


2017-06-13T21:42:44.090296Z mysqld_safe Logging to syslog.2017-06-13T21:42:44.094763Z mysqld_safe Logging to '/var/log/mysql/error.log'.2017-06-13T21:42:44.099027Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

Then I needed to create the /var/run/mysqld directory and set property to the mysql, otherwise was not possible to login:


mkdir -p /var/run/mysqld

chown mysql:mysql /var/run/mysqld


After this issue this tutorial helped me.

By: Natan Felles

Also the Password field name is authentication_string now.


update user set authentication_string=PASSWORD('new-password') where user='root';


By: Aera23


Note: Since I use Dan's hosting (hosting danwin1210 me), the MySQL password is stored in the "dashboard" when I log in, so I can't forget it (and the hosting pass is in my AutoFill and mental memory)