[Solved] MySQL: Access denied for user ‘username’@’host’ (using password: YES) error in Workbench, HeidiSQL
Before reading this article,
please note that in this case ” Access denied for user ‘username’@’host’ (using password: YES) “ error is appeared while connecting SQL server hosted on Webhosting (cPanel) and user is trying to connect from his local PC.
SQL Error (1045) in statement #0: Access denied for user ‘username’@’host’ (using password: YES)
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 is appeared even after entering the correct username and password.
👈 Access denied for user ‘username’@’host’ (using password: YES)
HeidiSQL database tool.
Even if you try to connect MySQL server using different database tools like Workbench, Navicat for MySQL, etc problem will not get solved.
Fixing ” Access denied for user ‘username’@’host’ (using password: YES) error”
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.
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 in the given screenshot.
Click on Remote MySQL, it will open the configuration screen.
2 Add access host
From here you have to allow the IP address to access the SQL server from database tools like Workbench, HeidiSQL installed on your local PC.
You have three options here
- add “%“, it is wild card entry it will allow all IPs to access SQL server with login credentials
- add fixed IP (for example: 188.8.131.52), only if you have one
- 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.
After this step, retry connecting. The problem should have been solved.
If not check your username and password again and check if your tools are allowed through the firewall.