8

I have MAMP installed and I've never had a problem with it. Today I tried logging in to PHPMyAdmin and I got the following error message:

1045 - Access denied for user 'root'@'localhost' (using password: YES)

enter image description here

In my config.inc.php file, the following options are set:

$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)? $cfg['Servers'][$i]['user'] = 'root'; // MySQL user $cfg['Servers'][$i]['password'] = 'root'; 

I've never changed my password. This is a local install, so I've always used 'root' for username and password.

I've tried accessing MySQL through the terminal:

/Applications/MAMP/Library/bin/mysql 

But I get this:

ERROR 1045 (28000): Access denied for user 'boneill'@'localhost' (using password: NO) 

Not sure what could have happened. I haven't changed passwords or anything like that. It just stopped working all of a sudden. Any ideas?

7
  • Try not to use any password, and check what port you are using Commented Jun 17, 2017 at 23:05
  • Try that where/how? All I'm doing is starting MAMP servers and trying to navigate to PHPMyAdmin and I get the error. Commented Jun 17, 2017 at 23:06
  • And ports: Apache: 80, Ngnix: 8888, MySQL: 3306 Commented Jun 17, 2017 at 23:08
  • $cfg['Servers'][$i]['password'] = 'root'; remove this line, if it doesn't work, check in mamp setting to check if you are using the right port Commented Jun 17, 2017 at 23:08
  • Also try 127.0.0.1 instead of localhost Commented Jun 17, 2017 at 23:09

4 Answers 4

36
  1. Start MAMP

The MySQL server must be running to change the password, open and start MAMP now. keep it running until the end of this.

  1. Mac Terminal

With the MySQL server running, open the terminal (located in '/Applications/Utilities') enter or copy/paste the following:

/Applications/MAMP/Library/bin/mysqladmin -u root -p password 

You'll be prompted for a password. Enter the current password for the root user. If you changed it in phpMyAdmin, use that password.

Mosty password is blank so just press Enter and Enter Your New Password.

$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password Enter password: $ /Applications/MAMP/Library/bin/mysqladmin -u root -p password Enter password: New password: Confirm new password: 

Now You Have to make changes in some file:

You need to replace all occurrences of the old root password with the new one you just created. To keep it easy here is a list of the files, you can open them in your favorite text editor and search for 'root', changing '-proot' to '-p NewPassword', replacing 'NewPassword' with your own.

  • /Applications/MAMP/bin/phpMyAdmin/config.inc.php
  • /Applications/MAMP/bin/checkMysql.sh
  • /Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
  • /Applications/MAMP/bin/repairMysql.sh
  • /Applications/MAMP/bin/stopMysql.sh
  • /Applications/MAMP/bin/upgradeMysql.sh

    Stop and restart MAMP

I hope that works/make sense because this works for me.

Sign up to request clarification or add additional context in comments.

1 Comment

This usually happens when you changed the password of db root user outside of MAMP itself - or even through it and then upgraded versions. I had this problem on MAMP PRO after a upgrade from V6.3 to V6.4, The answer by @harsh_shah is still valid except that MAMP V6.4 now has both V4.9 and V5.1 of phpMyAdmin integrated I am still not sure the mechanism of having both under the hood especially it uses port 3306 by V4.9 and port 8889 by V5.1. Before you mess this up, you may go ahead to further upgrade to V6.4.2 it "seemly" fix the password issue. However to me it still sounds buggy.
2

If I were you, I would just take your htdocs folder and just reinstall mamp. I've had this issue occur installing wordpress locally, setting the config file with a db user without a password, and then changing the password after the config was created in the installation process. I don't know why I did this but this installed wordpress with a user without a password, when the database required a password, so it then was giving me an authentication error.

Comments

0

Taking into consideration that you seem to have trouble debugging the issue, I think the most easiest way to rule out some of the probabilities is to install:

MySQL Workbench

It's free and you can use it as a GUI to try logging in to "localhost" or better "127.0.0.1" port 3306, user "root", password as you've chosen.

If you still notice an error connecting to the database, go to control panel -> services and check the status of the MySQL database. It might have crashed. Try to restart the service. If it shuts down again immediately, check your disk space. If you are running low on disk space, tables might have got corrupted. Also, check your firewall rules. If you are working in a corporate environment, somebody may have deployed new security polices - this might lead to port blocking, application networking issues etc. pp. -- even on your local host. Automatic windows updates might cause those changes too.


If it works using MySQL workbench, you can rule out any issue on database side. You can focus on PHP / MAMP then. Check the version and if any update has been installed (probably automatically). Is php mysql module installed and configured (php.ini, ensure php mysql dll is loaded).

Comments

-1
  1. Go to MAMP dashboard and Click on MySQL tab.
  2. There button called "Change password for user "root":
  3. Click on the button and change it.
  4. Thats it.

3 Comments

Just noting, the person cannot access this section of MYSQL because he's getting this error.
There's no option in the MAMP Pro interface to change the MySQL root password, though I'm on version 6.6 on macOS Big Sur.
At the time of writing this comment, you can only change the password in this section if you stop the server first. Then the change password button should be enabled. You can enter a new password and then restart the server (saving the changes in the process).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.