~ 1 minute
If you forgot root password for your MySQL database server running under Microsoft Windows, there is still a way to access your database and even reset your password using the command prompt.
Follow next steps:
1. Stop your MySQL server completely. This can be done from Wamp(if you use it), or start “services.msc” using Run window, and stop the service there.
2. Open your MS-DOS command prompt using “cmd” inside the Run window. Then go to your MySQL bin folder, such as C:\MySQL\bin. Path is different if you use Wamp.
3. Execute the following command in the command prompt:
mysqld.exe -u root --skip-grant-tables
4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.
5. Go to your MySQL bin folder again.
6. Enter “mysql” and press enter.
7. You should now have the MySQL command prompt working. Type “use mysql;” so that we switch to the “mysql” database.
8. Execute the following command to update the password:
UPDATE user SET Password = PASSWORD('your_new_passowrd') WHERE User = 'root';
However, you can now run almost any SQL command that you wish.
After you are finished close the first command prompt, and type “exit;” in the second command prompt.
You can now start the MySQL service. That’s it.
If you liked the post, we should get connected - follow me on Twitter
I don’t know how old this post is but I just wanted to say thanks.
This method worked when two other methods didn’t.
Great, I’m glad to hear that! Cheers ;)
Really worked ! Thanks a ton! :)
Hi Jole,
I am getting this
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
while executing 6th step
I had the same error! running first command as Administrator solved my problem.
It worked for me. Thanks!!!
Wow! Thanks Jole. Worked perfectly.
Just a perfect job Jole. It worked well. Thanks a lot !
Worked as a charm. Nice tip! Thanks.
It’s a great article! I was searching and searching for a long to find out a solution like this. Take my best wishes :)
Really really … really thanks, it’s work prefect for my mysql server 5.1
Just Thanks!
AMAZING!!!!!!!!!!!!! Thank you sooooo much!!!!!!!!! i am soooo grateful to u! :’D
you are my hero.
Oh man you ave me a lot time…it’s really helpful as well as a very easy method. :)
Thank you!
Thanks a ton. These steps are really simple and useful.
you gave me life by saving my time.thanks man. great work. very simple straight fwd explanation love u man.
friendly
krishna
Thank you so much.. it’s very helpful and time saving….
Thanks bro. it’s very helpful.
If you still have access to the DB via gui (in my case I had access to the DB via HeidiSql), please make sure you flush your privileges (e.g. FLUSH PRIVILEGES;) after you run your update statement.
Thank you for this great post!
Thanks. This is good tutorials.
Pingback: Locked yourself out of MySQL: reset the root password | Miraz Al-Mamun
Thank you so much … it worked perfectly… :)
Works great
Thank you so much! It worked perfectly! :) Saved me a lot of time. hehe
Thanks a lot, I’ve been struggling with that problem for ages, very efficient solution.
Perfect tutorial !
Thank you so much ! You saved my day :)
After failing a few times with other websites, I came across this and it worked perfectly. Thanks.
Thanks, this help me a lot :)
It worked like magic. Thank you very very much for this post.
Amazing. After few time !! finally, a real solution !!!
OMG, its working,, thanks
This worked!! I have been trying to get my lost password reset for some time now and nothing seem to work. I can’t thank you enough..
Pingback: Reset Forgotten MySql root Password Under Windows | PHP DEVELOPER ZONE
This really worked! But I had to run the MS-DOS Command Prompt as administrator… Is that because I’m using Windows 8.1?
Sjajno, hvala! Cheers!
OMG I was searching maybe for 2 hours trying to find something that will work and after doing this method It REALLY WORKED!!! THANKS MAN!
Worked like a charm. Thank you for your easy to follow to the point post :)
Finally, you are the tenth website I have visited and yours is the only one who easily helped me fix it. I don’t know where I’d be if I had lost my database. Thank a million!
OMG THIS FIXED MYSQL AND MY LOVE LIFE!!! Thanks!!! Actually I strongly emphasize adding a FLUSH PRIVILEGES; statement after the password update as someone else recommended in the post.
You are a genius, saved me, this procedure works fine, Thankyou so much!!!!
Very nice way to make someone understand, how to reset password… Many thanks jole…
Hi Jole,
It is not working for me while executing 6th step :
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
thank you so much it’s helpfull….:) muaacchh
If you have root access to the server where mysql is running you should stop the mysql server using this command
sudo service mysql stop
Now start mysql using this command
sudo /usr/sbin/mysqld –skip-grant-tables –skip-networking &
Now you can login to mysql using
sudo mysql
FLUSH PRIVILEGES;
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘MyNewPass’);
Full instructions can be found here http://www.techmatterz.com/recover-mysql-root-password/
Thank you !!This helped me.
Hi,
Just great – I had used as MYSQL generated password & managed to lock myself out?OUCH. These instructions are exact and clear. I’m back in.
Thank you very much.
MySQL documentation is like 90s webpages and it’s hard to read but your guide was simple. Thanks
Super – thanks dude
Thank you! The official documentation didn’t work, but this did.
Still working!
Great!!. Thanks a lot.
It worked for me, thanks
Thanks, all work fine.
Thanks a lot. I struggle to get a password . Now I got. Thank u so much
Thanks Jole. It worked for me :)
Thanks Jole… It was really helpful…
Thank you jole……… it was really helpful.
simple and well documented.
awesome helpful
This been a good tutorial, especially on my end. I will be going to follow those instructions you had just explain on my Windows whenever it happened the same thing.
Thanks alot.Was seriously helpful…..!!!!
This worked in 2019… Thanks a lot!!!
Thanks a lot. it works !
Thanks… I’ve use this method in my win10 mysql 5.6 portable and success…
Many thanks bro., you save from a month headache and stress
Worked like magic! Thank you
tons and tons of thank you.
Pingback: MariaDB Root Issue | Echo4Golf Clear
Very informative article.
It worked for me too. (: