Just moved, migrated or restored your WordPress site and now see a database error? Work through this checklist on the new server.
WordPressSite migrationBackup restoreShared hosting & VPSโฑ About 15 minutes
Quick answer: After a move, "Error establishing a database connection" almost always means wp-config.php still holds the old server's database details, or the database was not fully imported on the new server. Create the database and user on the new server, import the full backup, then update all four database values in wp-config.php to match the new server.
|
You are here The error started after you moved, migrated or restored the site |
| Nothing movedThe error appeared on a site that was working โ |
| VPS or dedicated serverYou need server-level checks: logs, service, permissions โ |
A WordPress site has two parts: the files (including wp-config.php) and the database (posts, pages, settings and users). Copying the files is not enough. The database must be recreated on the new server, and wp-config.php must be told where it is. If any of the four connection details still point to the old server, WordPress cannot connect.
| What often goes wrong in a move | Step |
|---|---|
| Your domain still points to the old server | Step 1 |
| The database import stopped part-way or failed | Step 2 |
| The database user was not created or not assigned on the new server | Step 3 |
wp-config.php still has the old name, user, password or host |
Step 4 |
| ๐ฆ | Keep the database backup (.sql or .sql.gz file) from the old server. If the old hosting is still active, do not cancel it until the new site works. |
| ๐ | Have access to the new server's control panel (SolidCP, WebsitePanel or Plesk) and its File Manager or FTP. |
After a move, your domain can keep pointing to the old server for some hours while DNS changes spread. The error may come from the old site, for example if its database was already deleted.
nslookup yourdomain.com
๐ก Tip: To test the new server before DNS changes, add a line to your computer's hosts file that maps your domain to the new server's IP address. Remove the line when you are finished.
wp_options, wp_posts and wp_users. Your tables may start with a different prefix than wp_.| Import problem | What to do |
|---|---|
Unknown collation: 'utf8mb4_0900_ai_ci' |
The backup came from MySQL 8 and the new server runs an older MySQL or MariaDB. Open the .sql file in a text editor, replace every utf8mb4_0900_ai_ci with utf8mb4_unicode_ci, save and import again. |
| File too large, or the import times out | Upload a compressed .sql.gz file. On a VPS, import from the command line with the mysql client. On shared hosting, open a support ticket and we can help with the import. |
Table ... already exists |
An earlier attempt partly worked. Import into a new, empty database, or remove the existing tables first (only if nothing else uses that database). |
Database users are not copied with the backup. They must exist on the new server.
wp-config.php in the site's main folder on the new server.define( 'DB_NAME', 'new_database_name' ); define( 'DB_USER', 'new_database_user' ); define( 'DB_PASSWORD', 'new_database_password' ); define( 'DB_HOST', 'localhost' );
DB_HOST to localhost, unless your SoftSys welcome email or control panel gives a different database server name. Do not keep the old host's server name.โ ๏ธ Password with a quote mark? If the password contains a single quote ('), it ends the text early and breaks the line. Put a backslash before it (\'), or choose a new password without quote marks.
If the error is gone but WordPress asks you to install it again, it is connected to the database but cannot find its tables. The table prefix in wp-config.php does not match the imported tables.
wpab_options means the prefix is wpab_.wp-config.php, make the prefix line match:
$table_prefix = 'wpab_';
โ๏ธ The move is complete when:
nslookup shows the new server's IP address./wp-admin with your usual WordPress username and password.Only cancel or delete the old hosting once all three are true.
The database is stored by the database server, not in the site's files. It has to be exported from the old server and imported on the new one as a separate step.
Their computers are still reaching the old server because DNS changes take time to spread, often a few hours and sometimes up to 48 hours. Keep the old hosting running until the change has spread.
Yes, open a support ticket to ask about help with the move, including the database import.
Still seeing the error after the move?
Tell us your domain, where the site was moved from, and which step above failed. We will help you get it connected.
| How to Fix 'Error Establishing a Database Connection' in WordPress โ |
| WordPress Database Connection Error: Advanced VPS Diagnostics โ |
| How to Fix the HTTP 500 Internal Server Error in WordPress โ |