xampp localhost phpmyadmin Access denied for user 'root'@'localhost' (using password: YES)

xampp localhost phpmyadmin Access denied for user 'root'@'localhost' (using password: YES)

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

Stefan Bogdanescu

Founder & Senior Architect

xampp localhost phpmyadmin Access denied for user 'root'@'localhost' (using password: YES)

When you encounter the error Access denied for user 'root'@'localhost' (using password: YES) in phpMyAdmin, the diagnosis is straightforward but often overlooked. The message explicitly states that the connection parameters provided to the MySQL server do not match the credentials stored within it. In your specific configuration snippet, you have set $cfg['Servers'][$i]['auth_type'] = 'config', which instructs phpMyAdmin to use the hardcoded values defined in config.inc.php. However, you are telling the system to connect using a password ('password') while simultaneously setting $cfg['Servers'][$i]['AllowNoPassword'] = false. This combination forces phpMyAdmin to send an authentication packet with that specific string. If the MySQL server running on your local machine expects no password for the root user, or if the stored password is different, the handshake fails immediately.

The most common cause in a local XAMPP environment is a mismatch between what you think the default credentials are and what the actual installation holds. By default, many XAMPP distributions install MySQL with an empty root password. If your configuration file contains $cfg['Servers'][$i]['password'] = 'password'; but your database expects an empty string, the connection will be rejected. To resolve this, you must align the phpMyAdmin configuration with the reality of your database instance.

You can verify the actual stored password by accessing the MySQL command line or using another client like HeidiSQL or a browser-based admin tool if available. Run the following query to inspect the user accounts:

SELECT User, Host, Password_Lex, Authentication_string, Plugin FROM mysql.user WHERE User = 'root';

If Authentication_string is empty or null, your root account has no password set. In this case, you must clear the password field in your phpMyAdmin configuration file:

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

It is crucial to understand that $cfg['Servers'][$i]['AllowNoPassword'] = false does not mean "allow connections if no password is set"; it means "enforce that a password must be sent in the authentication packet." If your database has an empty password, sending a non-empty string (like 'password') causes the mismatch. Conversely, if you intend to set a strong password for security, you must update the root user in the MySQL database itself first, not just in phpMyAdmin.

Another potential pitfall involves the authentication method and host specification. Your config uses connect_type set to socket. This is generally correct for local XAMPP installations because it avoids TCP/IP overhead by using the Unix socket file located in /tmp. However, if you have previously configured your MySQL server to bind only to 127.0.0.1 and not localhost via the socket, or if permissions on the socket file are restrictive, this might contribute to connection issues. While less likely to cause an "Access denied" error specifically regarding authentication strings, it is worth ensuring that $cfg['Servers'][$i]['host'] remains localhost unless you have explicitly changed your MySQL bind address in my.ini.

Regarding the commented-out sections in your code, such as $cfg['Servers'][$i]['pmadb'] or $cfg['Servers'][$i]['bookmarktable'], these are entirely safe to leave commented out. These options enable advanced features like SQL bookmarks and relation tables that store data in specific MySQL tables. If you uncomment them without first creating the corresponding database and tables, phpMyAdmin will attempt to write to non-existent locations, often resulting in errors or warnings. Unless you have explicitly created a phpmyadmin database and populated these schema elements, keeping them commented is the recommended approach for a standard local setup. Similarly, the $cfg['blowfish_secret'] parameter is required for cookie-based authentication (auth_type = cookie), but since you are using config-based authentication, this field can remain empty.

In summary, the error stems from a password mismatch. Ensure that the string assigned to $cfg['Servers'][$i]['password'] exactly matches the authentication string stored in the mysql.user table for the root user on localhost. If you have never set a password, clear the config value to an empty string and ensure AllowNoPassword is handled correctly relative to your specific server setup.

Our network