When This Error Happens
You type your MySQL username and password into phpMyAdmin, hit Go, and instead of your databases you get a red box: Cannot connect: invalid settings. This tripped me up the first time I moved from MySQL 5.7 to MySQL 8 on a Windows 10 machine running XAMPP 8.2. I spent two hours thinking my password was wrong. It wasn't.
What's Actually Wrong
The error means phpMyAdmin can't reach the MySQL server, or the authentication details in the config file don't match what MySQL expects. The default config.inc.php file points to localhost on port 3306, but MySQL 8 sometimes uses a different socket or has strict auth caching. Also, if you changed the MySQL root password after installation, the config file still has the old one.
Most people don't realize phpMyAdmin has its own config file separate from MySQL. You edit that file, and suddenly things work. Let's fix yours.
Fix It in 5 Steps
Step 1: Find config.inc.php
Locate the file config.inc.php in your phpMyAdmin folder. On XAMPP, it's at C:\xampp\phpMyAdmin\config.inc.php. On Ubuntu with Apache, try /etc/phpmyadmin/config.inc.php. If you don't see one, copy config.sample.inc.php to config.inc.php.
Step 2: Check the Host and Port
Open the file in Notepad or VS Code. Look for this line:
$cfg['Servers'][$i]['host'] = 'localhost';
If MySQL runs on the same machine, keep localhost. But if you use a different port (like 3307 or 3308), change this line too:
$cfg['Servers'][$i]['port'] = '3306';
On some Linux setups, MySQL listens on a socket file instead of TCP. Change the host to 127.0.0.1 — that forces a TCP connection and often fixes the socket issue.
Step 3: Set the Right Auth Type
Look for this line:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
The default cookie is fine — it shows a login screen. If someone changed it to config, you'll see a blank login or errors. Stick with 'cookie' unless you know exactly what you're doing.
Step 4: Verify the Username and Password (if auth_type is config)
If the file has these lines:
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
And you changed your MySQL root password, update password. But better yet, use auth_type = 'cookie' and leave the password blank — you'll type it each login. That's safer anyway.
Step 5: Restart Everything
After saving the file, restart Apache and MySQL. On XAMPP, click Stop then Start for both services. On Linux, run:
sudo systemctl restart apache2
sudo systemctl restart mysql
Then reload phpMyAdmin in your browser. Try logging in with the same MySQL credentials you use in the command line.
If It Still Fails
Check these three things:
- MySQL is actually running. Open a terminal and type
mysql -u root -p. If it says "Can't connect" or "Access denied", fix MySQL first — phpMyAdmin won't work until it does. - Firewall or antivirus is blocking port 3306. On Windows, check Windows Defender Firewall. On Linux, check UFW or iptables. Temporarily disable the firewall to test, then add an exception.
- phpMyAdmin version mismatch. If you're running phpMyAdmin 5.x with MySQL 8.0+, you're fine. But if you use an old version (like 4.x) with MySQL 8, upgrade phpMyAdmin. Download the latest from phpmyadmin.net.
That's it. Nine times out of ten, it's the host setting or a wrong port. Change those, and you're back to managing databases.