reset mysql password in windows


If you find these instructions confusing, here’s another method.  

1.  Find the my.ini file (my.cnf for linux).  On windows, the my.ini file is typically in your install directory: c:\Program Files\MySQL\MySQL Server 5.1\my.ini   Open the file with notepad (or any text editor) and add the following entry under the [mysqld] section:

skip-grant-tables

Then, save the file and restart the MySQL service.  This has disabled the grant tables so you should be able to log into mysql without any password ( no more 1045 errors ).  Now, we need to reset the password.  

2.  Log into MySQL with the MySQL command-line utility.  This can be found in the MySQL bin directory.  No user or password parameters are required since grant tables have been disabled.  Execute the following statement:

UPDATE mysql.user SET PASSWORD = PASSWORD(”) WHERE user = ‘root’ and host=’localhost’;

This example will replace the root password with an empty string or no password.  Feel free to substitute the appropriate password in the PASSWORD(”) function or leave it blank and change the password later.

3.  Remove “skip-grant-tables’ from the my.ini file and restart the MySQL service.

4.  Log into mysql.  Example: shell>mysql -u root

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: