Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAMP and PHPMyAdmin: #1045 - Access denied for user 'root'@'localhost' (using password: YES) [duplicate]

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?

like image 782
Brian O'Neill Avatar asked Nov 28 '22 20:11

Brian O'Neill


2 Answers

  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.

like image 83
Harsh Shah Avatar answered Nov 30 '22 08:11

Harsh Shah


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.

like image 22
JORDANO Avatar answered Nov 30 '22 10:11

JORDANO