Decoding the phpMyAdmin Access Denied Error on XAMPP
The error mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' is a classic symptom of a misconfiguration between phpMyAdmin's internal authentication mechanism and your MySQL server. While the stack trace points to a connection failure, the specific detail (using password: NO) reveals the root cause: phpMyAdmin is attempting to authenticate as the system user pma without providing any credentials.
In the context of XAMPP, this is almost exclusively an issue with file permissions rather than missing passwords or incorrect database names. The configuration file you provided correctly sets $cfg['Servers'][$i]['controluser'] = 'pma'. This setting tells phpMyAdmin to use the pma system account for advanced features like managing users via SQL queries. However, if the underlying operating system does not grant this user permission to execute the necessary commands, the connection attempt fails immediately with an access denied error.
The Role of File Permissions
The critical missing piece in your setup is the ownership of the config.inc.php file. When phpMyAdmin runs, it executes code within the context of the Apache process or a specific system user (often named pma on Linux systems, though XAMPP for Windows behaves differently regarding internal accounts). If the web server process does not own the configuration file, it cannot write to the temporary files required for session management and advanced SQL operations.
On a standard Linux or macOS setup running Apache, you must ensure that the config.inc.php file is owned by the system user designated for phpMyAdmin's control access. If $cfg['Servers'][$i]['controluser'] is set to pma, your shell user (or root) must own this file so that the process can interact with it correctly.
You can verify and fix the ownership using the following commands:
# Check current ownership
ls -l /path/to/config.inc.php
# Set ownership to 'pma' user if it matches your controluser setting
sudo chown pma:pma /path/to/config.inc.php
# Ensure permissions are writable by the owner but not world-readable (security best practice)
sudo chmod 640 /path/to/config.inc.php
If you are running XAMPP on Windows, the concept of a system user named pma for authentication is less common unless specifically configured. In many XAMPP installations, the default behavior relies on the web server's ability to read the file. If you have explicitly set $cfg['Servers'][$i]['controluser'] = 'pma' but do not have a corresponding system user defined with that name and no password, you might need to clear this directive entirely if you are not using advanced SQL user management features.
Clearing the Control Password
Your configuration shows $cfg['Servers'][$i]['controlpass'] = ''. This is correct only if the pma system user has no password. However, if your MySQL server was configured with a password for this specific account, or if the file permissions prevent the web server from reading the config due to ownership issues, the connection will fail.
If you intend to keep the controluser setting active, ensure that the pma user exists in your system's user list (on Linux/macOS) and has no password set, matching the empty string in your config. If you are on Windows, consider removing the $cfg['Servers'][$i]['controluser'] and $cfg['Servers'][$i]['controlpass'] lines entirely to revert to standard cookie-based authentication unless you have a specific need for SQL-level user management via the interface.
Verifying the Database Tables
Another potential pitfall is the existence of the meta tables. Your config references pma__users, pma__bookmark, and others within the phpmyadmin database. If these tables do not exist, phpMyAdmin may attempt to create them using the control user credentials. If that connection fails due to permission issues (as hinted by the error), the setup appears broken.
Run this SQL check to ensure the meta database exists:
USE `phpmyadmin`;
SHOW TABLES;
If tables are missing, you can recreate them using phpMyAdmin's built-in installer or manually creating them via the command line. However, remember that if the initial connection fails due to permission errors, you may need to grant permissions to your MySQL root user first:
GRANT ALL PRIVILEGES ON `phpmyadmin`.* TO 'pma'@'localhost';
FLUSH PRIVILEGES;
Note that this assumes a pma database user exists in your MySQL instance. If you are running XAMPP, check whether the default installation expects the web server to run as www-data, _apache, or simply the current Windows user. Mismatched expectations between the config file's ownership and the Apache process's identity will perpetuate the error regardless of password resets.
