Troubleshooting phpMyAdmin: Fixing the MySQL "Access Denied" Error (HY000/1045)
Setting up your local web development environment can occasionally run into configuration hiccups. One of the most common issues occurs after installing XAMPP when you attempt to open phpMyAdmin and are greeted by a glaring red error box like the one in image_5dbd95.png:
MySQL said:
Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/1045): Access Denied for user 'root'@'localhost' (using password: NO)
This message can feel frustrating, but it means something very specific: phpMyAdmin is attempting to log in to your MySQL database with a blank password, but the database server is actively rejecting it because a password actually exists.
Here is a comprehensive guide to understanding why this happens and exactly how to fix it.
Why Is This Error Happening?
By default, a brand-new XAMPP installation configures both MySQL and phpMyAdmin to use the username root with a completely blank password.
If you are seeing the error in image_5dbd95.png, one of two things has happened:
-
You altered the password: You previously set a password for the
rootuser (via phpMyAdmin or the terminal) but forgot to update phpMyAdmin’s underlying configuration file.
2. A port conflict is occurring: You have another, older instance of MySQL Server (like a standalone installer or an instance bundled with an app like Docker) running silently in the background. XAMPP's phpMyAdmin is accidentally routing into that database instead of the fresh XAMPP database.
Detailed Solutions to Fix the Connection
Follow these steps in order to sync phpMyAdmin back up with your database.
Solution 1: Update config.inc.php with Your Password
If you know or remember the password you set for your MySQL database, you simply need to hand it over to phpMyAdmin.
- Open your file explorer and navigate to your XAMPP installation directory:
Default Path:
C:\xampp\phpMyAdmin\Look for the file named
config.inc.phpand open it using a plain text editor like Notepad, Notepad++, or VS Code.Scroll down to the Authentication type and info section (typically around lines 18–25).
Locate the line containing the password configuration:
$cfg['Servers'][$i]['password'] = '';
5. Type your database password inside the empty single quotes:
php
$cfg['Servers'][$i]['password'] = 'YourActualPasswordHere';
6. **Save the file** and refresh `http://localhost/phpmyadmin` in your web browser.
---
### Solution 2: Turn on the Visual Login Screen
If you aren't sure what the password is and want to try a few common development credentials manually, you can tell phpMyAdmin to stop logging in automatically and display a login prompt instead.
1. Open that same `C:\xampp\phpMyAdmin\config.inc.php` file.
2. Locate the authentication type setting:
php
$cfg['Servers'][$i]['auth_type'] = 'config';
php
- Change
'config'to'cookie':
$cfg['Servers'][$i]['auth_type'] = 'cookie';
- Save the file and reload phpMyAdmin. You will now see a username and password challenge box.
5. Try combinations like root / root, root / admin, or any standard local passwords you typically use.
Solution 3: Check for and Stop Background MySQL Services
If you never intentionally set a password, a ghost MySQL service running on your machine is likely hijacking port 3306.
To verify and fix this:
- Press the
Windows Key + Rto open the Run dialog box. - Type
services.mscand press Enter. - Scroll down through your local Windows Services list and look for anything named
MySQL,MySQL80, orMariaDB. - If the service status reads Running, right-click it and select Stop.
- Go back to your XAMPP Control Panel, click Stop next to MySQL, and then click Start to relaunch XAMPP's database cleanly.
- Refresh your browser page to check if access is restored.
Solution 4: Force a Reset of the Root Password
If all else fails and you are locked out of your local playground, you can force MySQL to reset its root password back to nothing via the XAMPP Command Line.
- Open the XAMPP Control Panel and stop the MySQL service if it is running.
- Click the Shell button on the right side of the Control Panel interface.
- In the command prompt window that opens, run the database engine while bypassing permissions checking by typing:
mysqld --skip-grant-tables
- Leave that window open. Click the Shell button in the XAMPP Control Panel again to open a secondary terminal window.
- In the new window, type
mysqland press enter to log in instantly. - Run the following SQL queries to wipe the password clean:
ALTER USER 'root'@'localhost' IDENTIFIED BY '';
FLUSH PRIVILEGES;
EXIT;
- Open Windows Task Manager (
Ctrl + Shift + Esc), terminate any activemysqld.exeprocesses, and start MySQL normally from the XAMPP Control Panel.
Conclusion
The using password: NO error looks scary, but it is ultimately just a basic communication mix-up between phpMyAdmin and MySQL. Keeping XAMPP isolated from background installations and keeping your config.inc.php file aligned with your actual administrative credentials will permanently keep this error at bay.