简体   繁体   中英

Error #1045 on phpMyAdmin - Access Denied Mac

The full error is #1045 - Access denied for user 'root'@'localhost' (using password: YES)

I am on a Mac, using mamp. This was working just a few weeks ago and I am not sure what happened. I have looked through countless overflow posts and still can't find the problem. Mamp shows me that my host is localhost, port is 8889, and the username and password are both 'root'.


Config File

$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;


There is also the problem when I go to localhost/phpmyadmin/setup where it says 'Please create web server writable folder config in phpMyAdmin top level directory as described in documentation. Otherwise you will be only able to download or display it.'

I DO have a folder called config.

It appears as if you have lost your MySQL root password. To confirm, you can try accessing the MySQL command line client . From the command line client/Terminal, try running the mysql command: /Applications/MAMP/Library/bin/mysql --host=localhost -u root -p root

If you connect successfully then the problem lies elsewhere, but it seems the password is not actually "root" and I suggest you try to reset it.

The usual disclaimers apply, of course. This process shouldn't affect any of your underlying data.

This person has great step-by-step directions with photos: http://www.tech-otaku.com/local-server/resetting-mamp-mysql-root-user-password/

Basically you need to open the MAMP control page and stop servers. Then restart the server with the --skip-grant-tables option:

/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 &

Enter the MySQL application: /Applications/MAMP/Library/bin/mysql

Reset the password: UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';

You can use whatever password you want inside the PASSWORD function, however MAMP might be expecting this to be 'root' and may have issues if you deviate. You could edit the MAMP configuration to reflect your new password, but that's beyond the scope of this answer.

The article I linked suggests that you FLUSH PRIVILEGES; at this point, but I think since you're about to restart the server that you can skip that step.

Quit the command line client with CTRL-D or \\q

Shut down the MySQL server: /Applications/MAMP/Library/bin/mysqladmin --socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown -u root -p

Then go back to the MAMP control panel and click Start Servers. Try logging in again.

You may also wish to refer to the official MySQL manual on the matter: https://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM