[Solved] MySQL: Access denied for user ‘username’@’host’ (using password: YES) Error in Workbench, HeidiSQL

Trying to make SQL connection using database tools like Workbench or Heidi SQL and stuck due to the error message “MySQL Access denied for user”. It is annoying because even after the message is meaning full we don’t have an exact idea what is messed up!

In this article, we will see the possible causes of this error and how to fix it in two common scenarios.

Causes of “Access denied for user ‘username’@’host’ (using password: YES) error”

Generally, this ” Access denied for user ‘username’@’host’ (using password: YES) ” occurs because of one of the following reasons,

  1. The user tries to access the database with an invalid login username & password
  2. When there are no privileges for the tried user
  3. Login access is blocked by hosting server settings

In the first case, you just have to recheck login credentials. If you lost your login password, then you have to reset it. Refer to this guide: MySQL: How to Reset the Root Password

In other cases, we will see how to fix it.

Fix error when MySQL installed on the same system

In this case ” Access denied for user ‘username’@’host’ (using password: YES) ” error has appeared while connecting SQL server hosted on Webhosting (cPanel) and the user is trying to connect from his local PC. While connecting to an SQL server hosted on your web hosting service provider using database tools like MySQL Workbench or HeidiSQL sometimes the following error may occur

SQL Error (1045) in statement #0: Access denied for user ‘username’@’host’ (using password: YES)

The error message popup screenshot is as follows,

Access denied for user ‘username@host using password YES in heidi
Access denied for user ‘username’@’host’ (using password: YES)
Error in
HeidiSQL database tool.

Since this error is also associated with an invalid username and password, some forums suggesting to check login credentials. But in this case, the error appeared even after entering the correct username and password.

Even if you try to connect the MySQL server using different database tools like Workbench, Navicat for MySQL, etc problem will not get solved.

Fix error when MySQL is installed on the remote-hosted server

In our side troubleshooting, we found that the connection from the outside world is blocked by the server by default for security reasons. This is a normal security provision arranged by a web hosting company to avoid unauthorized access.

To solve this problem, you have to either allow your static IP or give a wildcard ‘%’ entry.

Step-1: Access Remote MySQL from your web hosting cPanel

Log into your web hosting cPanel, and then look for the “Remote MySQL” icon under the database section. It will look like this in the given screenshot.

remote mysql from cPanel
Remote MySQL in cPanel

Click on Remote MySQL, it will open the configuration screen.

Step-2: Add access host

From here you have to allow the IP address to access the SQL server from database tools like Workbench, and HeidiSQL installed on your local PC.
You have three options here

  1. add “%“, it is a wild card entry it will allow all IPs to access the SQL server with login credentials
  2. add fixed IP (for example:, only if you have one
  3. add IP range if you are using multiple IPs (for example 174.77.92.%.)

Remember Allowing ‘%’ all IP to access DB creates a large security hole, always use strong login credentials.

add access host
Add Access Host in cPanel

Step 3: Retry the connection

After this step, retry connecting. The problem “Access denied for user ‘username” should have been solved. If not check your username and password again and check if your tools are allowed through the firewall.

Leave a Comment

Related Posts