FAQ Migrations & Transfers

How to migrate just the database

Export, create an empty database on the new server, import, then point the application at it — the files do not need to move at all.

Updated 5 min read Intermediate

Sometimes the files are staying put and only the database needs to move — a common case when an application connects to a database hosted separately from its files, or when you are consolidating several databases onto one server. The process is shorter than a full site migration but follows the same principle: export cleanly, prove the new copy works, then switch the connection over.

Step 1 — Export the current database

From phpMyAdmin, select the database and use Export with the default settings, which produces a single .sql file containing both the structure and the data. From the command line, the equivalent is:

mysqldump -u user -p databasename > backup.sql

Keep this file somewhere safe until the new database is confirmed working — it is your way back if anything goes wrong.

Step 2 — Create an empty database on the new server

Create a new, empty database and a user with access to it. Note the database name, username and password exactly — a typo here is the most common reason the next step fails.

Step 3 — Import into the new database

For a small database, phpMyAdmin's import tool handles the .sql file directly. For anything larger than the upload limit your browser or phpMyAdmin allows — commonly around 50MB — the command line avoids the limit entirely:

mysql -u newuser -p newdatabase < backup.sql

If the export is very large, see importing a database too large for phpMyAdmin for options such as compressing the file first or importing in stages.

Step 4 — Point the application at the new database

Update the application's configuration with the new database name, username, password and host:

PlatformFile to edit
WordPresswp-config.php
Laravel.env
Joomlaconfiguration.php
Drupalsites/default/settings.php

Note that the database host is often localhost only when the database sits on the same server as the files. If it is genuinely a separate server, you will need the actual hostname or IP address supplied by whoever hosts the database.

Step 5 — Test before removing the old database

Load the application and confirm it connects and behaves normally, including anything that writes to the database, not just pages that read from it. A database connection error at this stage almost always means one of the four values in step 4 does not match — see fixing a database connection error if that happens.

Keep the old database until you are certain

Do not delete the original database immediately, even once the new one appears to be working. Leave it in place, untouched, for a few days while the application runs normally against the new one. If something surfaces that only shows up under real use, the old database is still there to fall back to or compare against.

Moving the whole site, not just the database?

Our full migration guide covers files, database, DNS and email together, and website migration is included free with our hosting plans — get in touch if you would like it done for you.

Related reading