The "Access Denied for User" error occurs when a MySQL or MariaDB database rejects a connection attempt because the provided credentials (username or password) are incorrect or the user does not have permission to access the specific database. This issue typically affects customers attempting to connect via a web application, a local management tool like MySQL Workbench, or a script.
Before you begin
You will need:
Access to your hosting control panel (such as cPanel or Windows Control Panel).
The specific database name, username, and password provided by your hosting provider or set during the database creation process.
The specific tool or application you are using to connect to the database.
Check connection credentials
The most common cause of this error is a typo or an incorrect password in the application's configuration file.
Identify the configuration file for your application (e.g.,
wp-config.phpfor WordPress or.envfor many other frameworks).Locate the database connection section.
Verify that the DB_NAME, DB_USER, and DB_PASSWORD fields exactly match the credentials provided in your hosting control panel.
Ensure there are no extra spaces or hidden characters in the fields.
Save the file and attempt to connect again.
Check user permissions and privileges
Even if the password is correct, the user must have been granted permission to access the specific database.
Log in to your hosting control panel.
Navigate to the MySQL Databases or Database section.
Locate the database you are trying to access.
Verify that the user is listed under that database and has been assigned the appropriate privileges (typically "All Privileges").
If the user is not listed or has restricted permissions, remove the user and re-add them to the database to refresh the permissions.
Verify the host address
If you are trying to connect from a local machine or a remote server, the "Access Denied" error may occur because the database is only listening for local connections.
Check the "Host" or "Server" field in your application's connection settings.
If you are connecting from the same server where the website is hosted, the host should typically be
localhostor127.0.0.1.If you are connecting from a remote location, ensure you have authorized your specific IP address in the hosting control panel.
Check for remote IP restrictions
If you are using a tool like MySQL Workbench to connect to your database from a remote location, the connection may be blocked by a firewall or a "Remote MySQL" restriction.
Log in to your hosting control panel.
Locate the Remote MySQL or Allowed Hosts section.
Add your current public IP address to the allowed list.
Attempt the connection again.
Contact Hostek support
If you have verified that your credentials are correct, the user is assigned to the correct database, and your IP is allowed, but you still receive an "Access Denied" error, please contact Hostek support.
Provide the following information to help us investigate:
The specific error message (e.g., "Access denied for user 'username'@'localhost'").
The database name and the username you are using.
The IP address from which you are attempting to connect.
The tool or application you are using to connect.
