How to Migrate a WordPress Database (2026 Guide)
2026-11-23
How to export and migrate a WordPress database with phpMyAdmin, WP-CLI or a plugin, without breaking serialized data or table prefixes.
Your WordPress database holds almost everything that makes your site yours: posts, pages, users, comments, menus, widget settings, plugin options, WooCommerce orders. The files (themes, plugins, uploads) are the easy part of a move. The database is where migrations go wrong.
This guide shows how to export and migrate a WordPress database three ways: with phpMyAdmin, with WP-CLI, and with a plugin, and which pitfalls to avoid with each.
What's in a WordPress database
A standard install has about a dozen tables, all starting with a prefix (wp_ by default):
wp_postsandwp_postmeta: posts, pages, menus, attachments, page-builder datawp_usersandwp_usermeta: accounts and roleswp_options: site URL, settings, theme and plugin optionswp_comments,wp_termsand friends: comments, categories, tags
Plugins add their own tables. The database name, user and password are in wp-config.php, along with the $table_prefix line.
How to export a WordPress database with phpMyAdmin
Most hosts include phpMyAdmin in their control panel.
- Open phpMyAdmin and click your WordPress database in the left column. (Not sure which one? Check
DB_NAMEinwp-config.php.) - Click Export.
- Choose Quick and the SQL format for small sites, or Custom to compress the output (gzip) for bigger ones.
- Click Export and save the
.sqlfile.
Import it on the new server
- Create an empty database and a user with full rights on it in the new host's control panel.
- Open phpMyAdmin, select the new database, click Import, choose your file and start.
- Update
DB_NAME,DB_USER,DB_PASSWORDandDB_HOSTin the new site'swp-config.php.
The catch: phpMyAdmin imports through a normal upload, so it's bound by the host's upload limit and PHP time limit. A database of a few hundred megabytes often times out halfway, which leaves you with some tables imported and others missing.
How to export a WordPress database with WP-CLI
If you have SSH access, WP-CLI is faster and has no upload limit.
On the old server, inside the WordPress folder:
wp db export backup.sql
Copy backup.sql to the new server (for example with scp), then on the new server:
wp db import backup.sql
No WP-CLI? mysqldump -u USER -p DATABASE > backup.sql and mysql -u USER -p DATABASE < backup.sql do the same job.
The step everyone gets wrong: changing URLs in the database
If the domain or the folder changes, the database is full of the old address. The tempting fix is to open the .sql file in a text editor, or run sed, and replace oldsite.com with newsite.com. Don't.
Why serialized data breaks
WordPress and plugins store arrays and objects as serialized PHP strings, and each string records its own length:
s:22:"https://oldsite.com/x/";
Replace the domain with one of a different length and that 22 is now wrong. PHP can't unserialize the value, and WordPress quietly treats it as empty. The result: missing widgets, reset theme options, lost plugin settings, broken page-builder layouts, with no error message to tell you why.
Page builders add more variants: URLs in JSON with escaped slashes (https:\/\/oldsite.com) and URL-encoded values (https%3A%2F%2Foldsite.com). A simple replace misses those entirely.
Use a serialization-aware search and replace
WP-CLI handles serialized data correctly:
wp search-replace 'https://oldsite.com' 'https://newsite.com' --all-tables --dry-run
Check how many replacements the dry run reports, then run it again without --dry-run. Run extra passes for other forms of the address if your site uses them (for example http:// or www.).
Watch the table prefix
If the old site used a custom prefix like wpx7_, the imported tables keep it. The new wp-config.php must have the same value:
$table_prefix = 'wpx7_';
If you decide to change the prefix, renaming the tables isn't enough. WordPress also stores the prefix inside the data: the wpx7_user_roles option in the options table, and the wpx7_capabilities and wpx7_user_level keys in the usermeta table. Miss those and you'll log in to a message saying you don't have permission to access the dashboard.
Other database migration pitfalls
- Character set mismatch. Export and import with the same charset (normally
utf8mb4), or accents and emoji turn into garbage. - Old MySQL on the new server. A dump from MySQL 8 may use a collation that an older MariaDB doesn't know. Check versions before you move.
- Partial imports. If an import stops halfway, drop the tables and start over rather than continuing on top of a half-imported database.
- A live site during the import. Importing straight over the live tables means visitors see a broken site until it finishes, or forever if it fails.
The plugin way: migrate the database and files in one go
A migration plugin removes every step above. With NoLimit Migration, the database travels inside the same backup as your media, themes and plugins:
- On the old site, open NoLimit Migration → Backup / Export and make a backup. Leave out spam comments, revisions and transients to shrink the database, and exclude any tables you don't need.
- In Backups, click Transfer link (or Download the file).
- On the new site, open Restore / Import, paste the link into Import from URL (or drop the file on the upload area) and click Restore now.
What it handles for you:
- No size or time limit. The backup moves in small resumable pieces, so a large database doesn't time out like it can in phpMyAdmin.
- Safe import. The database is imported into temporary tables next to the live ones and switched in at once with a single rename. A failed import never leaves a half-restored site, and visitors see a maintenance page while it runs.
- Restore point first. Before every restore, NoLimit backs up the current site automatically.
- URLs replaced correctly, inside serialized data, JSON and URL-encoded values, plus your own find & replace rules.
Prefer the command line? NoLimit has WP-CLI commands too: wp nolimit backup, wp nolimit list, wp nolimit link, wp nolimit fetch and wp nolimit restore.
Manual vs plugin: which should you use?
| phpMyAdmin | WP-CLI | NoLimit Migration | |
|---|---|---|---|
| Needs SSH | No | Yes | No |
| Upload/time limits | Yes | No | No |
| Safe on serialized data | No (needs an extra tool) | Yes, with search-replace | Yes, automatic |
| Live site safe if import fails | No | No | Yes |
| Moves files too | No | No | Yes |
FAQ
Can I move only the database?
Yes, with phpMyAdmin or wp db export. Just remember to fix the URLs with a serialization-aware tool afterwards.
Where is the WordPress database stored?
On the MySQL or MariaDB server your host provides, not in your site's folder. wp-config.php tells WordPress how to reach it.
Why do I get "Error establishing a database connection" after the move?
The database details in wp-config.php don't match the new server. Check the name, user, password and host.
Migrate your database the easy way
Download NoLimit Migration free and move the database and files together, safely. For the full move, see how to migrate a WordPress site or compare the best WordPress migration plugins. Want it done for you? Our migration service starts at $49.