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

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

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

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

When you see Access denied for user 'root'@'localhost' in your browser, it usually means MySQL is rejecting a connection attempt based on host verification or authentication method mismatches. In the specific scenario described with WAMP Server 5.5.24 and phpMyAdmin 5.5.24, the error message explicitly states "using password: NO". This indicates that while your database credentials might be valid for some hosts, MySQL is refusing to authenticate root from localhost because it expects a password or has cached a different authentication plugin configuration.

The fact that accessing via 127.0.0.1/phpmyadmin works perfectly while localhost/phpmyadmin fails is the critical diagnostic clue. In MySQL and MariaDB, localhost and 127.0.0.1 are treated as distinct host specifications. When phpMyAdmin connects to localhost, it often resolves via a Unix socket or a TCP connection that MySQL treats differently than the IP address. If you recently changed the root user's password in phpMyAdmin, you may have inadvertently updated the mysql.user table with a new authentication plugin (like caching_sha2_password) or altered the host mask, causing a disconnect for the specific socket-based login attempt used by the default localhost configuration.

To revert this without reinstalling WAMP, you must bypass phpMyAdmin's interface entirely and manipulate the MySQL user tables directly using the command line. Since your root password currently has no value, you can log into MySQL as an administrator to reset the credentials. Open a Command Prompt (cmd) or PowerShell, navigate to your WAMP installation directory, and stop the Apache and MySQL services to ensure a clean state:

wampstop

Once stopped, start the MySQL console directly from the WAMP folder:

mysql -u root -p

If you have no password set, simply press Enter after typing root. If prompted for a password and it works without one, you are in the correct session. Once inside the MySQL prompt, run the following SQL commands to inspect and fix the user configuration:

-- First, check the current authentication plugin and host
SELECT User, Host, plugin FROM mysql.user WHERE User = 'root';

-- If the plugin is caching_sha2_password but you are using an older client or socket config 
-- that expects mysql_native_password, update the plugin specifically for localhost
UPDATE mysql.user 
SET plugin = 'mysql_native_password' 
WHERE User = 'root' AND Host = 'localhost';

-- Alternatively, if the issue is simply that the password was changed to something other than empty:
-- You must set the password here. Since you want it back to "no password", 
-- MySQL 5.7+ and 8.0 do not support truly empty passwords in some configurations,
-- but you can set a known strong password if security is a concern.
-- If you insist on no password, ensure the user is granted privileges without a hash:

UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User='root';

FLUSH PRIVILEGES;
EXIT;

After resetting the user table, restart the WAMP stack to apply changes:

wampstart

Now, open your browser again and navigate to localhost/phpmyadmin. If the error persists, check your phpMyAdmin configuration file located at \wamp\bin\php\phpX.X\phpMyAdmin\config.inc.php. Look for the $cfg['blowfish_secret'] or authentication settings. Sometimes, phpMyAdmin caches the connection string based on the dbhost setting. Ensure that inside config.inc.php, the $cfg['Servers'][$i]['auth_type'] is set to cookie and not http, which can cause host resolution conflicts.

If you previously edited the password in phpMyAdmin, it might have written an incorrect hash into the configuration cache. Deleting the cached configuration file (often found in your browser's local storage or a PHP session file) can help, but the database-level fix via the command line is the most reliable method for WAMP environments. This approach ensures that the root@localhost user aligns with the authentication expectations of both the TCP/IP and Unix socket connections, resolving the discrepancy between localhost and 127.0.0.1.

Our network