You try to connect to MySQL using a database tool like Workbench or HeidiSQL, and then this shows up: “MySQL Access denied for user”. Annoying, right? The message is meaningful enough, but it still doesn’t tell you exactly what got messed up.
Here, we’ll go through the likely causes of this error and the fix for two common situations.
In this article,
Why the “Access denied for user ‘username’@’host’ (using password: YES)” error happens
Most of the time, the “Access denied for user ‘username’@’host’ (using password: YES)” error comes down to one of these reasons.
- The user is trying to access the database with the wrong login username or password
- The user being tried doesn’t have the required privileges
- Login access is blocked by the hosting server settings
For the first case, recheck the login credentials. If you’ve lost the login password, you’ll need to reset it. Refer to this guide: MySQL: How to Reset the Root Password
For the other cases, here’s how to fix it.
Fix the error when MySQL is installed on the same system
In this case, the “Access denied for user ‘username’@’host’ (using password: YES)” error appeared while connecting to an SQL server hosted on Webhosting, from a local PC. While connecting to an SQL server hosted with your web hosting service provider using database tools like MySQL Workbench or HeidiSQL, you may sometimes see the following error.
SQL Error (1045) in statement #0: Access denied for user ‘username’@’host’ (using password: YES)
The error message popup screenshot looks like this.
![[Solved] MySQL: Access denied for user 'username'@'host' (using password: YES) Error in Workbench, HeidiSQL 1 Access denied for user ‘username@host using password YES in heidi](https://techiesdiary.com/wp-content/uploads/2014/01/Access-denied-for-user-‘username@host-using-password-YES-in-heidi.jpg)
Error in
HeidiSQL database tool.
Because this error is also linked with an invalid username and password, some forums suggest checking the login credentials. But here, the error showed up even after entering the correct username and password.
Trying another database tool won’t usually fix it either. Workbench, Navicat for MySQL, and similar tools can still show the same problem.
Fix the error when MySQL is installed on a remote-hosted server
From our troubleshooting, we found that the server blocks connections from the outside world by default for security reasons. That’s a normal security setting used by a web hosting company to avoid unauthorized access.
To fix the problem, you have to allow your static IP or add a wildcard ‘%’ entry.
Step 1 Access Remote MySQL from your web hosting cPanel
Log into your web hosting cPanel, then look for the “Remote MySQL” icon under the database section. It will look like the screenshot given below.
![[Solved] MySQL: Access denied for user 'username'@'host' (using password: YES) Error in Workbench, HeidiSQL 2 remote mysql from cPanel](https://techiesdiary.com/wp-content/uploads/2021/09/remote-mysql-from-cPanel-1024x544.jpg)
Click Remote MySQL, and the configuration screen will open.
Step 2 Add access host
From here, you need to allow the IP address that will access the SQL server from database tools like Workbench and HeidiSQL installed on your local PC.
You have three options here
- Add “%“. This is a wildcard entry, and it will allow all IPs to access the SQL server with login credentials
- Add a fixed IP, for example: 24.54.155.12, only if you have one
- Add an IP range if you’re using multiple IPs, for example 174.77.92.%.
Remember, allowing ‘%’ so all IPs can access the DB creates a large security hole. Always use strong login credentials.
![[Solved] MySQL: Access denied for user 'username'@'host' (using password: YES) Error in Workbench, HeidiSQL 3 add access host](https://techiesdiary.com/wp-content/uploads/2021/09/add-access-host-1024x435.jpg)
Step 3 Retry the connection
After this step, retry connecting. The “Access denied for user ‘username” problem should be solved. If it isn’t, check your username and password again, and also check whether your tools are allowed through the firewall.

