MySQL Forums
Forum List  »  Install & Repo

Solution to: Error Nr. 1045 Access denied for user 'root'@'localhost' (Using password: NO) - Or password: YES
Posted by: George Edmonds
Date: May 21, 2010 11:48AM

So I had this same problem and after reading a post or two it dawned on me what the problem was... So to hopefully resolve this issue for other people I created a quick batch file...

Just Copy everything below between the @ECHO OFF and @ECHO ON into a batch ".bat" file and place it in your bin directory...

This batch file makes a few assumptions:
1. That MySQL is installed on C:
2. That the My.ini is in one directory above your bin directory
3. The MySQL service was installed as "MySQL"

When you run this file, it may hang when you get to:

"Version: '5.1.46-community' socket: '' port: 3306 MySQL Community Server (GPL)"

If it does, just hit ctrl-c It will then ask you if you want to terminate the batch job... Tell it no.


Once it starts the Instance Config again, run through the steps. For the current password use "isreset" (without the quotes). Thats it...

Hopefully this saves people the hassle of uninstalling, cleaning, and reinstalling...

What the batch file essentially does:
1. Stops the mysql service
2. Starts the mysqld serivice with an init file that resets the password to isreset.
3. Starts the Instance Config wizard.

Here is the batch file contents.
Place in your bin folder as something like fix.bat

@echo off
cls
NET STOP MySQL
copy ..\my.ini c:\my.ini
echo UPDATE mysql.user SET Password=PASSWORD('isreset') WHERE User='root'; > c:\reset.pass
echo FLUSH PRIVILEGES; >> c:\reset.pass
mysqld-nt --defaults-file="c:\my.ini" --init-file="c:\reset.pass" --console
mysqld --defaults-file="c:\my.ini" --init-file="c:\reset.pass" --console
NET STOP MySQL
cls
ECHO Completed resetting password.
del c:\my.ini
del c:\reset.pass
ECHO Starting MySQL Instance Config
ECHO Please use the password "isreset" without the quotes to complete the instance config.
MySQLInstanceConfig.exe
ECHO DONE!
pause
@echo on

Options: ReplyQuote


Subject
Written By
Posted
August 23, 2010 05:37AM
October 08, 2010 02:25PM
Solution to: Error Nr. 1045 Access denied for user 'root'@'localhost' (Using password: NO) - Or password: YES
May 21, 2010 11:48AM
October 15, 2011 11:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.