How to Fix XAMPP phpMyAdmin Access Denied (Error 1045 Access Denied for root)

Advertisement

Google AdSense In-Article Display Placement

Publisher ID: ca-pub-XXXXXXXXXXXXXXXX (Configured in config.php)

When opening http://localhost/phpmyadmin returns "#1045 - Access denied for user 'root'@'localhost' (using password: NO/YES)", there is a password mismatch between XAMPP config.inc.php and the MySQL user table.

✔ Rapid Direct Solution

Open "C:\xampp\phpMyAdmin\config.inc.php" in your code editor. Locate $cfg['Servers'][$i]['password'] and make sure the password matches what you set for MySQL root, or reset the root password in MySQL console using ALTER USER 'root'@'localhost' IDENTIFIED BY ''; if using default empty password.

1. Problem Diagnosis & Symptoms

phpMyAdmin automatically signs in using the credentials defined in config.inc.php. If you updated the root user password via phpMyAdmin User Accounts or CLI, phpMyAdmin continues attempting to log in with the old credentials, resulting in access denial.

2. Primary Root Causes

  • Cause: Changed MySQL root password without updating config.inc.php.
  • Cause: Auth type mismatch: config mode vs cookie authentication.

3. Step-by-Step Diagnostic Fixes

1

Update config.inc.php with the Matching Password

Edit C:\xampp\phpMyAdmin\config.inc.php.

PHP
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'YourNewPassword';
$cfg['Servers'][$i]['auth_type'] = 'config';

4. How to Verify the Resolution

  • ✔ Open http://localhost/phpmyadmin in browser.

5. Diagnostic Troubleshooting Matrix

Symptom Observed Root Cause Recommended Action
Access denied (using password: NO) MySQL root user has password, but config.inc.php sends empty password Add password to config.inc.php

6. Critical Mistakes to Avoid

  • ❌ Never delete phpmyadmin folder to reset access.

7. Frequently Asked Questions

❓ Can I switch phpMyAdmin to prompt for login with username and password?

Yes! Change $cfg['Servers'][$i]['auth_type'] from 'config' to 'cookie'.

Official Technical References

Advertisement

Google AdSense In-Article Matched Content Unit