Solution for 1045: Access denied for user ‘root’@'localhost’ on MAMP

Here is the solution that I got from messing around the system for a day.

I have a Mac Mini which was running Mac OS X Tiger with MAMP server installed. Today the electricity just went out without warning, and my box got shutdown when the MySQL transaction was in progress.

When the server got back up and running a few minutes later, the MAMP MySQL module can’t seem to connect to the MySQL server due to access denied for user ‘root@localhost’.

I couldn’t even change the password or create a new user using Terminal. Tried all the suggestions found on the net, and no luck.

The solution is simple.

Open:

/Applications/MAMP/db/mysql/mysql/user.MYD using TextEdit.app

If your password was ‘root’ then the MD5 encryption is 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B

See if the encrypted password was there. Mine was having an extra ‘+’ after the last ‘B’. Delete the ‘+’ and restart MAMP. Boom! Everything back to normal.

If your password was something else, try using an online MD5 encryption to find out what your MD5 encryption is and compare it againts the one in your user.MYD file.

 

DON’T FORGET TO BACKUP YOUR FILE(S) BEFORE DOING THIS

 

 

Post to Twitter Post to Delicious Post to Facebook Post to MySpace

2 Comments

BillJune 2nd, 2011 at 8:37 am

Similar problem, MySQL error # 1045 access denied for user. I am trying to add a database to a PHP file in Dreamweaver CS5.5. I am using MAMP PRO to generate my local host. I have checked the user name, server, and password – everything seems to be correct. Web URL in testing server was tested and checks out. Any ideas or suggestions would be helpful. Thanks.

fernandoDecember 16th, 2011 at 3:09 am

In my case I had a ‘-’
delete it and give me the error again

#1045 – Access denied for user ‘fernando’@'localhost’ (using password: YES)
Connection for controluser as defined in your configuration failed.

i have user name root and password root
i open phpMyAdmin whit “http://localhost:8888/phpMyAdmin/”
and work

Leave a comment

Your comment


You might also be interested in: