Resolving phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Nov 16, 2025 · Programming · 18 views · 7.8

Keywords: phpMyAdmin | MySQL Connection Error | XAMPP Configuration

Abstract: This paper provides an in-depth analysis of MySQL connection error 1045 in phpMyAdmin within XAMPP environments, focusing on control user configuration issues. Through detailed examination of key parameters in config.inc.php configuration files, it offers solutions for creating pma users and properly configuring control user information. Combining Q&A data and reference materials, the article systematically explains error causes, diagnostic methods, and repair procedures to help developers completely resolve this common problem.

Error Analysis and Background

When deploying phpMyAdmin in XAMPP integrated environments, developers frequently encounter MySQL connection error 1045, specifically manifested as: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO). The core issue of this error lies in improper configuration of phpMyAdmin's advanced features control user.

Root Cause Analysis

From the provided configuration file, the problem primarily occurs in the following configuration section:

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

This configures a control user named 'pma' with an empty password. However, this user account does not exist in the MySQL server, or the user lacks appropriate access permissions, resulting in connection refusal.

Solution Implementation

To resolve this issue, action is required at two levels: MySQL user management and phpMyAdmin configuration adjustment.

MySQL User Creation

First, create the corresponding control user in MySQL. This can be done through the MySQL command-line tool by executing the following operations:

CREATE USER 'pma'@'localhost' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost';
FLUSH PRIVILEGES;

This creates a local user 'pma' and grants all privileges on the phpmyadmin database. The password should be set to a strong password to ensure security.

Configuration File Modification

In the config.inc.php file, update the control user configuration information:

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'your_password_here';

Ensure the password exactly matches the user password set in MySQL. For XAMPP environments, the configuration file is typically located at xampp\phpMyAdmin\config.inc.php.

Configuration Verification and Testing

After completing the above configuration, restart the MySQL service to make the changes effective. Verify the configuration correctness through the following steps:

  1. Restart the MySQL service in XAMPP
  2. Re-access the phpMyAdmin interface
  3. Check if connection errors still occur
  4. Verify whether advanced features (such as relation view, bookmarks, etc.) work properly

Security Considerations

During the configuration process, pay attention to the following security considerations:

Alternative Solutions Discussion

Besides creating dedicated control users, other solutions can be considered:

Conclusion

phpMyAdmin's 1045 connection error typically originates from control user configuration issues. By properly creating MySQL users and synchronously updating phpMyAdmin configuration files, this problem can be effectively resolved. In practical operations, it's recommended to follow the principle of least privilege, ensuring system security while meeting functional requirements.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.