XAMPP中phpMyAdmin提示Wrong username/password. Access denied无法运行,该如何解决?
Hey, let’s fix that phpMyAdmin login error ("Wrong username/password. Access denied.") in your XAMPP setup step by step—this is a super common issue, and I’ve worked through it dozens of times. Here’s what to try:
XAMPP ships with a default phpMyAdmin setup where the username is root and the password is empty (yes, completely blank!). A lot of people accidentally fill in a password here, so first try logging in with:
- Username:
root - Password: (leave this field empty)
If that works, you’re done! If not, move on to the next steps.
PhpMyAdmin stores its login settings in the config.inc.php file, located in your XAMPP phpMyAdmin folder (e.g., C:\xampp\phpMyAdmin\config.inc.php on Windows, /Applications/XAMPP/xamppfiles/phpmyadmin/config.inc.php on macOS).
Open this file in a text editor and look for these lines:
$cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = '';
Make sure:
- The
uservalue isroot(unless you created a different MySQL user for phpMyAdmin) - The
passwordvalue matches your actual MySQL root password. If you never set a MySQL password, leave this empty.
Save the file, then restart both Apache and MySQL services in the XAMPP control panel. Try logging in again.
If you can’t remember your MySQL root password, here’s how to reset it:
- Stop the MySQL service in the XAMPP control panel.
- Open a command prompt (Windows) or terminal (macOS/Linux) and navigate to your XAMPP MySQL bin directory:
# Windows example cd C:\xampp\mysql\bin # macOS/Linux example cd /Applications/XAMPP/xamppfiles/bin - Start MySQL with permission checks disabled:
# Windows mysqld.exe --skip-grant-tables # macOS/Linux ./mysqld --skip-grant-tables - Leave that window open, and open a new command prompt/terminal. Navigate back to the MySQL bin directory, then log into MySQL:
mysql -u root - Once you’re in the MySQL shell, run these commands to reset the password (replace
your_new_passwordwith the password you want to use):USE mysql; -- For MySQL 5.6 and older UPDATE user SET password=PASSWORD('your_new_password') WHERE user='root'; -- For MySQL 5.7+ UPDATE user SET authentication_string=PASSWORD('your_new_password') WHERE user='root'; FLUSH PRIVILEGES; EXIT; - Close both command windows, restart the MySQL service in XAMPP, then update the
passwordline inconfig.inc.phpto match your new password. Try logging in again.
Sometimes the issue is simpler than you think—double-check that the MySQL service is actually running in the XAMPP control panel. If it says "Stopped", click "Start" to launch it, then refresh the phpMyAdmin page.
Occasionally, old cached login data in your browser can cause this error. Clear your browser’s cache and any cookies related to your local phpMyAdmin instance (usually localhost/phpmyadmin), then reopen the page and try logging in again.
内容的提问来源于stack exchange,提问作者sriya pathak




