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?

Community
  • 1
  • 1
Brian O'Neill
  • 4,705
  • 5
  • 22
  • 26

4 Answers4

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

Harsh Shah
  • 1,386
  • 14
  • 19
  • 1
    This tips help a lots. Thank you for feedback! – Didierh May 25 '20 at 22:19
  • 1
    Thank you. this was really an easy and quick one. – Hriju Sep 08 '20 at 21:17
  • 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. – seedme Jul 22 '21 at 00:56
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.

JORDANO
  • 726
  • 8
  • 17
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).

kyr0
  • 341
  • 4
  • 6
-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.
tapaljor
  • 237
  • 1
  • 6
  • 21
  • Just noting, the person cannot access this section of MYSQL because he's getting this error. – JORDANO Jun 05 '18 at 17:30
  • 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. – SteveExdia Mar 15 '22 at 16:03