Error establishing a database connection (access denied)

For hosting customers · Updated 2026-10-29

On this page
  1. Symptoms
  2. Causes
  3. Fix
  4. Still not working?

The website cannot sign in to its MySQL database. The database server answers, but the details in the site's configuration file do not match a database and user of your account — very often after a move, where names on this server are different.

Symptoms

  • WordPress: Error establishing a database connection.
  • SQLSTATE[HY000] [1045] Access denied for user 'example_wp'@'localhost' (using password: YES).
  • Unknown database 'example_wp' or SQLSTATE[HY000] [2002] No such file or directory / Connection refused.
  • A 500 error with one of these lines on the Errors page.

Causes

Most likely first:

  1. The database or user name lacks your account's prefix, or has another account's prefix after a move.
  2. The user has no privileges on the database (it was created but never added).
  3. The password in the configuration file is not the user's password.
  4. The database host is wrong — it must be localhost.
  5. Upper and lower case differ in the database name.
  6. The database does not exist on this server (it was not moved) or a table is damaged.

Fix

Compare the configuration with the panel

  1. Open MySQL Databases (section Databases). Note the exact database names, the users, and which users are listed under Privileged users of each database.
  2. Open the site's configuration file in File Manager (section Files) with Edit: wp-config.php for WordPress (DB_NAME, DB_USER, DB_PASSWORD, DB_HOST), configuration.php for Joomla, .env for Laravel, app/etc/env.php for Magento, and so on.

1. Name prefix

Every database and database user name starts with your username and an underscore, for example username_wp. Use the full names exactly as shown on MySQL Databases.

2. Privileges

Under Add user to database, choose the user and the database and click Grant all privileges.

3. Password

Next to the user, enter a New password and click Change, then put the same password in the configuration file and save. (The password needs at least 8 characters with 3 of: lowercase, uppercase, digits, symbols.) Watch for quotes: a password containing ' or $ must be written the way the file's language expects.

4. Host

Use localhost as the database host. Database users sign in from this server through localhost; the server's public address or a domain name as host gives "Access denied" or no connection. To connect from another computer, allow its address in Remote MySQL (section Databases).

5. Upper and lower case

Database names are case-sensitive on this server: example_DB and example_db are different databases. Use the name exactly as listed.

6. Missing database or damaged table

  • If the database is not listed, it was not moved: create it, then import its .sql export with Open phpMyAdmin (Import).
  • If the error mentions a crashed or damaged table, click Check & repair next to the database. If a table cannot be repaired, the message names it: restore the database from Backups (section Advanced).

Still not working?

  • If all sites of the server fail at once, the database server may be down: tell your host. Administrators check the mysql service (mariadb) in Service Manager; the watchdog restarts it when it stops.
  • If your host has turned on the AI assistant, click Explain with AI on the Errors page or Fix with the assistant on Site Check.
Was this article helpful?

Still stuck?

Ask the AI about your exact situation — it answers from this knowledge base — or contact us.