Softpedia
 

NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home > News > Webmaster > Tips and Tricks

September 28th, 2007, 15:07 GMT · By Adrian Placinta

How to Reset Root Password on MySQL

SHARE:

Adjust text size:



Enlarge picture
One of the most disturbing and embarrassing situations is when you forget a password. And if that password is from your MySQL server, you are in big trouble. But every time there is a solution for every problem. You can set-up a new password using the following method.

In Windows environment, make sure you are logged in as Administrator. If you installed MySQL as services, stop it from Services manager,.
You can find it in Control Panel -> Administrative Tools -> Services. If you didn't install it as services, kill it from Task Manager. Next you will have to create a text document where you will insert SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NewPassword'); , save the document with any name (I recommend you to use mysql_new_password.txt).

Next, open command prompt and execute the following command: C:> C:mysql inmysqld --init-file=C:mysql_new_password.txt. The command from the text document is executed after --init-file option. When you will start the server, the command from C:mysql_new_password.txt is executed and this will reset the password. Another thing that you should know is that if you installed MySQL using MySQL Installation Wizard you must specify another option: --defaults-file. So, the command will be:

C:> "C:/Program Files/MySQL/MySQL Server 5.1/bin/mysqld.exe"
--defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini"
--init-file=C:/mysql_new_password.txt


If you don't know the setting for --defaults-file, you can find it in Services Manager: Control Panel -> Administrative Tools -> Services. From there look for MySQL service, right-click on it, choose properties and in Path to executable you will find the setting for --defaults-file.

The final step is to restart the MySQL server from the Service Manager (if you installed MySQL as service) or use the restart command from the command prompt. From now, you can login using the new password.

This is the solution for the problem. There is another solution which is the simplest possible: don't forget your passwords. :)

TELL US WHAT YOU THINK:

14,123 hits · 2 comments · Link to this article · Print article · Send to friend · Subscribe to news

MUST-READ RELATED ARTICLES:


How to Assign a Password to the Root Account on MySQL

How to Secure Accounts in MySQL

How to Secure Your Password for MySQL

READER COMMENTS:


Comment #1 by: Lokesh on 20 Nov 2008, 17:46 UTC reply to this comment

Thanks for helping me out. I spent couple of hours before I found this solution that worked.


Comment #2 by: doman on 06 Oct 2009, 19:43 UTC reply to this comment

Who is using mysql on windows anyway?

Copyright © 2001-2012 Softpedia. Contact/Tip us at

WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM