If you receive a 1045 error, you may need to reset your password. Here are the official instructions for resetting the password: http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html
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
I hope this helps.
Hi,
Please see my following post: Dangers of skip-grant-tables, which discusses the options for resetting MySQL’s passwords.
In short: using skip-grant-tables requires 2 server restarts and makes for security risks. There is another way, described in the post.
Regards
Comment by Shlomi Noach — June 21, 2009 @ 4:48 am |
Last time I forgot my password and tried everything i could do but failed, until I found this great tool Password Genius. It works great, and you can google it.you can try to google it.
Comment by windowsofpassword — October 8, 2010 @ 7:57 am |
Many people tell me they have such problem. actually there is an easy way to solve it: use Windows Password Recovery(http://www.windowspassword-recovery.com/). Then you can recover your passwords in one minute!
Comment by rcmichelle — November 5, 2010 @ 9:08 am |
Thanks for mentioning the dangers of server restarts, it’s a good thing to take into consideration.
Comment by Duane Gordon — July 13, 2011 @ 10:05 pm |
Thanks a lot. I was trying to reset password using recomendded methods, but they did fail soon as I realized I do not have necessary files, i.e. mysqld-nt (do not know why). This method is fast and furious.
Comment by Warcin — October 13, 2011 @ 10:35 am |
UPDATE! [19/05/2012 ]
In version 1.7.7 of XAMPP in the directory: C:\xampp\mysql\resetroot.bat is for recovery the root…. I’m sorry for the vocabulary, i am not native englishman.
Comment by Marcos Freitas — May 19, 2012 @ 5:04 am |
correction, this recovery the BD created where he not show…. but not the permissions.
Comment by Marcos Freitas — May 19, 2012 @ 5:08 am |
Comment 6. UPDATE! [19/05/2012 ] worked great for me after I shut the server down. Yahoo!!!
Comment by Mike — July 17, 2012 @ 8:06 pm |
Already the mysql services has been stopped. as per the steps we have followed the first step.. mysql command line utility is not found in mysql directory.. from where we need to type the following command “UPDATE mysql.user SET PASSWORD = PASSWORD(”) WHERE user = ‘root’ and host=’localhost’;”
Please help us out of this..
Comment by Anonymous — August 27, 2012 @ 6:23 am |
Good day! Do you use Twitter? I’d like to follow you if that would be okay. I’m undoubtedly enjoying your blog and
look forward to new updates.
Comment by crack passwords — March 31, 2013 @ 2:04 pm |