A database connection error after a restore or migration
Why a restored or migrated site can lose its database connection, and how to fix it.
After restoring a backup or migrating an account from another control panel, a website can occasionally show a database connection error even though the database itself came across correctly. This almost always means the application's own configuration file still points at the database name, username, or password it used before, rather than the ones that actually exist on this account now.
Steps
- Open Databases for the account and note the exact database name and the username tied to it. Depending on how the account was set up, these are not always the same as they were on the original server.
- Open the application's configuration file through the File Manager and compare it against what you just noted. It's common for the username or database name in the file to no longer match, especially after a migration from a different control panel that used its own naming convention.
- Update the configuration file to match, or click Change password next to that database login on the Databases page and update the configuration file with the new one. Changing the password there keeps the account's own records in sync, so use that rather than changing it any other way.
Tip: a "wrong username" error and a "wrong password" error can look identical to an application. Always confirm the username matches first, since that's the more common cause after a migration.