Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix Access denied for user 'root'@'localhost' for phpMyAdmin

I'm using WAMP Server 2.2 on a PC. In phpMyAdmin (version 5.5.24) I edited the 'root' user (with 'localhost' host) and gave it a password of 'root'. This turned out to be a big mistake that I'm trying to revert. Now when I go to localhost/phpmyadmin/ I get the menu of databases on the left, but the main frame has an error that reads:

#1045 - Access denied for user 'root'@'localhost' (using password: NO) phpMyAdmin tried to connect to the MySQL server, and the server rejected the  connection. You should check the host, username and password in your  configuration and make sure that they correspond to the information given  by the administrator of the MySQL server. 

If I go to 127.0.0.1/phpmyadmin, I do not get the error and everything works fine.

I tried changing the user's password back to no password; I tried modifying config.inc.php file to add the new password (but that made phpMyAdmin error-out completely); I tried removing and recreating the root/localhost user. Nothing seems to work. The root/localhost user appears to have no password and all privileges, but the error remains.

Any ideas or how I can get this user's access back to normal without having to reinstall WAMP?

like image 795
Luke Avatar asked Oct 20 '13 20:10

Luke


People also ask

How do I fix MySQL error Access denied for user root localhost?

Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.


2 Answers

Find config.inc file under C:\wamp\apps\phpmyadmin3.5.1 Inside this file find this one line

$cfg['Servers'][$i]['password'] ="; 

and replace it with

$cfg['Servers'][$i]['password'] = 'Type your root password here'; 
like image 154
Nikhil G Avatar answered Sep 29 '22 12:09

Nikhil G


I had the same problem after i had changed the passwords in the database.. what i did was the editing of the updated password i had changed earlier and i didn't update in the config.inc.php and the same username under D:\xamp\phpMyAdmin\config.inc

$cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = **'root'**; $cfg['Servers'][$i]['password'] = **'epufhy**'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['AllowNoPassword'] = true; $cfg['Lang'] = ''; 
like image 29
Ezra A.Mosomi Avatar answered Sep 29 '22 12:09

Ezra A.Mosomi