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.
/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