How to Fix MySQL Access Denied Error
Fix MySQL access denied errors by checking credentials, host rules, and privileges.
Real example
You try to connect with HeidiSQL, phpMyAdmin, or the mysql command and see:
Access denied for user.
This usually means MySQL rejected the account because of the password, host, or permission settings.
Before you start
Possible causes
Step-by-step instructions
1. Check the exact error message
Read the full message carefully. It often shows both the rejected username and host.
If the message says 'user'@'192.168.0.10', the host part matters just as much as the username.
2. Test the login manually
Try connecting directly with the same values your application is using.
mysql -u username -p -h localhost
3. Check user and host entries
Review which host values are allowed for the MySQL user.
SELECT user, host FROM mysql.user;
4. Grant the correct privileges
If the account is missing privileges or the host entry is wrong, grant the required access.
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
Common mistakes
Assuming the password is the only problem when the actual issue is the host value.
Granting permissions to the wrong user@host combination.
Environment tips
Local server: test both localhost and 127.0.0.1.
Remote server: also check firewall, bind-address, and port 3306 access.
Final check
Most MySQL access denied errors are solved by verifying credentials first, then matching the correct user@host entry, and finally granting the correct privileges.
About this guide
Fix MySQL access denied errors by checking credentials, user host settings, and privileges.
How to follow this guide
- Check the exact error message
- Verify username, password, and host
- Check MySQL user host entries
- Grant the correct privileges
Why use this method?
MySQL access denied errors are usually caused by invalid credentials, wrong host rules, or missing privileges.