Guides

Step-by-step tutorials and practical fixes for databases, servers, and daily technical work.
Database Guides

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

You need access to MySQL or an admin account.
Know the username and host used for connection.
Be careful when editing privileges on production servers.

Possible causes

Wrong username or password
Wrong host such as localhost vs remote IP
User exists but privileges are missing
Application is connecting with the wrong account

Step-by-step instructions

1. Check the exact error message

Read the full message carefully. It often shows both the rejected username and host.

Example

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.

Command
mysql -u username -p -h localhost

3. Check user and host entries

Review which host values are allowed for the MySQL user.

SQL
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.

SQL
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

  1. Check the exact error message
  2. Verify username, password, and host
  3. Check MySQL user host entries
  4. Grant the correct privileges

Why use this method?

MySQL access denied errors are usually caused by invalid credentials, wrong host rules, or missing privileges.