Database Connection Error: How to Fix It (ISPmanager)

The messages "Error establishing a database connection", "Access denied for user" or "Unknown database" all mean the same thing: the site cannot log in to the database with the details stored in its settings.

Where the connection details are

CMSFile and settings
WordPresswp-config.php: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST
Joomlaconfiguration.php: $db, $user, $password, $host
OpenCartconfig.php and admin/config.php: DB_DATABASE, DB_USERNAME, DB_PASSWORD
Laravel and others.env: DB_DATABASE, DB_USERNAME, DB_PASSWORD

The file is in the site folder www/your-domain. You can open it in the File manager.

Check in order

  1. Database and user names — full names, as in the "Databases" list. A name may include the account prefix, so copy it from the list, not from the creation form.
  2. Server — localhost. Do not enter an IP address or the server name.
  3. Password — if you are not sure, set a new one: three dots on the database → "Database users" → change the password. Enter this password in the site's settings file right away.
  4. The database has a user — "Database users" must include the user named in the settings file.
Database list: exact database and user names
Database list: exact database and user names

After moving a site

The database and user names on the new hosting are almost always different from the old ones. Create a database (how to create a database), import the dump into it (database import) and enter the new details in the settings file.

Other causes

If everything matches and the error remains, contact support from your client area: include the site and the database name. Do not write the password in the ticket.

Questions and answers
The site's settings file has the wrong database name, user, password or server. Compare them with the "Databases" list; the server is localhost.
In "Databases": a name may include the account prefix, so copy it from the list.
Enter the new password in the site's settings file, for example DB_PASSWORD in wp-config.php.