4

I thoroughly searched StackOverflow and Google to find an answer to this and so far nothing has helped. It's killing me because my project was pretty much finished!

In the control panel in phpMyAdmin I changed the password for the root user from 'root' to a new password. When I quit working and came back to it I couldn't connect to the server through MAMP, receiving this error:

Checking MySQL databases failed. Error message: /Applications/MAMP/Library/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

And this error on my localhost page:

Error: Could not connect to MySQL server!

I tried many things to try to resolve this issue, most of which I found from other SO questions. They are as follows:

I tried a bunch of other things like changing the auth_type to html, adding controluser and controlpass, and other things but no luck. Nothing seems to work.

Community
  • 1
  • 1
mintfiend
  • 43
  • 1
  • 1
  • 3

10 Answers10

8

Seriously, this is super easy to solve. Edit this line in the phpmyadmin/config.ini.php:

$cfg['Servers'][$i]['auth_type'] = 'config';

Just replace "config" by "cookie", so your like now looks like this

$cfg['Servers'][$i]['auth_type'] = 'cookie';

Now you'll be asked your password.

ps.: undo all your previous edits to this file trying to solve the problem, and do not write the root password in it. If you don't remember your edits, just start over by using phpmyadmin/config.sample.ini.php

SenhorLucas
  • 1,337
  • 12
  • 12
3

If you have tried the old password and it still did not work, then you can try changing the password again.

http://www.mamp.info/en/documentation/faq.html#q9

EDIT

In order to debug if it is the MySQL or PHPMyAdmin that is the problem now, please try this.

Access MAMP's MySQL from Terminal

See if you can connect to mysql on the command line, if you can then we know it is your phpmyadmin config that is wrong, if not then it is the mysql server that is wrong.

Anigel
  • 3,435
  • 1
  • 17
  • 23
  • I did this and still have the same problems. I changed the password back to root, back to the new password, and made a completely new password while also updating the config file. Nothing. – mintfiend Jul 22 '13 at 18:14
  • Indeed. I quit MAMP before changing and restarted after making the changes. – mintfiend Jul 22 '13 at 18:31
  • In that case if MAMPs own instructions for changing the MAMP MySQL password are not working, I suggest you raise a bug with MAMP. Are you using the latest version? – Anigel Jul 22 '13 at 18:38
  • Yes, latest version. When I updated, I donwloaded the latest version, unzipped, copied all the new files except config. I replaced the new config file with the old config file. This was all before the password change I made in Admin. – mintfiend Jul 22 '13 at 18:59
  • This didn't work either. I get ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) EDIT: I forgot to turn on the servers. With the servers on it let me in. Now what? – mintfiend Jul 22 '13 at 19:21
  • Your problem is with the phpmyadmin config then. Could it be something like this http://stackoverflow.com/questions/10139422/mysql-and-phpmyadmin-config-inc-php-password-issue-on-mamp – Anigel Jul 22 '13 at 19:26
  • I was able to change the password in Terminal which finally got me back into phpMyAdmin localhost panel. From there I duplicated the root user priveleges to a new user and created a password for that user. I will change my settings in my php pages and see if it will connect. Will get back soon. – mintfiend Jul 22 '13 at 19:40
1

I ran into this problem as well. After installing MAMP I changed the root mySQL password using phpMyAdmin. After having done so, I started getting the 1045 access error message. I then tried changing the phpMyAdmin config file as the documentation instructs. The error, however, persisted.

I had been trying to use textedit.app to change the config file. After being baffled for about 30 minutes I noticed the character "'" in the config file was slightly different after using textedit.app. I then loaded the config file into NetBeans and made the changes (changed password from 'root') and everything worked fine. The only change I made to the config file was with the password.

Perhaps others are having the same issue with subtle changes in characters caused by the editor???

JEHR
  • 31
  • 3
1

Windows Solution:

Go to

C:\MAMP\bin\phpMyAdmin

modify file config.inc (in line 61 change password)

Save and it works!

caro
  • 11
  • 1
0

If you have root access (by way of SSH or by way of the console) to the machine that MySQL is running on, then you can change or reset the MySQL root password by following the procedure at: http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html.

mti2935
  • 11,465
  • 3
  • 29
  • 33
0

My access denied error was actually based on file permissions. I created this script to help me fix all the databases. I run it inside the mysql directory that contains a folder per database. Hope it helps others

vim fixperms.sh 

#!/bin/sh
for D in `find . -type d`
do
        echo $D;
        chown -R mysql:mysql $D;
        chmod -R 660 $D;
        chown mysql:mysql $D;
        chmod 700 $D;
done
echo Dont forget to restart mysql: /etc/init.d/mysqld restart;
dny238
  • 61
  • 5
0

I extracted this answer/information from Larry Ullmans PHP for the web book, and it worked for me.

Through your Windows browser access:

C:\xampp\phpMyAdmin

find the config.inc file, open it, change the following line:

$cfg['Servers'][i]['password'] = 'AND HERE INSERT THE PASSWORD YOU USED FOR ROOT'; 

Save the file, open phpmyadmin in your browser/localhost, and you are good to go.

patricus
  • 59,488
  • 15
  • 143
  • 145
Robin
  • 37
  • 2
0

this for for the users who uses mamp

1) Stop the MAMP Sarvers

2) From terminal paste following code

/Applications/MAMP/Library/bin/mysqld_safe --skip-grant-tables --skip-networking --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid &

3) Then log in mysql by using this code

/Applications/MAMP/Library/bin/mysql

4) Reset Mysql Root password by

UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root';

5) Press enter, then type:

FLUSH PRIVILEGES;
Simanto
  • 54
  • 4
0

How funny we change the password for security, but in order to successfully get it done and access phpMyadmin without issues, it needs to be typed in the configuration file where anyone can see it.

0

Instead of editing the config file in the 'phpMyAdmin' folder, edit the config file inside the 'phpMyAdmin5' folder.

starball
  • 20,030
  • 7
  • 43
  • 238