Tuesday, 15 January 2013

MAMP: Access denied! #1045 in phpMyAdmin

Have you accidentally changed your  'root' user password from PhpMyAdmin ?


I changed my 'root' user's password, without thinking properly.  From having the default password ('root'), I changed it to ('password'). I've encountered many issues after that.  Luckily (I don't know why), I was able to re-type a password, so I decided to leave it blank: Change Password > NO Password



I did a bit of research until I made it work again. 

The following steps helped me to fix my issue (please don't try it unless you're having the same issue)

1. Open your terminal Applications > Utilities > Terminal

Type the following:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot 

"-uroot stands for user:root / -proot stands for password:root"

In my case I had to type the following:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -p
the terminal asked me to Enter a password


Enter password:  (I left this empty as I didn't have a password set, so I pressed ENTER)

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 85
Server version: 5.1.44 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Then, I typed:
mysql> use mysql;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Now you have to re-set the password. I wouldn't  like to mess things up (more), so I went for the default password ('root'),  I've typed the following:

mysql> UPDATE mysql.user SET Password=PASSWORD("root") WHERE user="root";
Query OK, 1 row affected (0.07 sec)
Rows matched: 1  Changed: 1  Warnings: 0


Last step, flush the user's privileges:

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.08 sec)


Now, to make sure you're on the right direction, make sure your new password matches a config file on MAMP.
Go to:

  MAMP > Bin > PhpMyAdmin > config.inc.php 

Look for the following line of code:

 $cfg['Servers'][$i]['password']      =  'root';  <- type whatever password you've set. 


You should be able to log your PhpMyAdmin, however you might not be able to access some of your databases. This is because your user 'root' probably hasn't got all privileges.

Now, Click on any database that might allow you to enter the PRIVILEGES tab.

Got to 

 user: root >  EDIT

Database specific privileges
  (choose the DB you're having issues with) > Go

Select ALL Privileges > Tadah! 
You NOW should be able to enter your DB without any issues. 

Happy days!

Hope this works for you. 
As I said, If you haven't got the same issue as mine, please don't try it.