WordPress

How to Migrate a WordPress Site Without Breaking It

How to migrate a WordPress site to a new host or domain: back up, copy files, import the database, replace the URL safely, switch DNS, and check everything.

By wptaskify TeamUpdated Oct 18, 202610 min read
How to Migrate a WordPress Site Without Breaking It

Quick answer

To migrate a WordPress site, take a full backup (files and database), copy wp-content and wp-config.php to the new host, import the database into a new empty database, update the database details in wp-config.php, and, only if the address changes, replace the old URL with a tool that understands serialized data such as WP-CLI's search-replace. Test the new copy, then point your domain's DNS to the new host and keep the old host running for a few days.

The six steps of a WordPress migration

Whether you use a plugin, your host's free migration service or do it by hand, every WordPress move is the same six steps underneath. Knowing them helps you spot what a tool skipped.

Six steps of a WordPress migration: back up, copy files, import database, update wp-config, replace the old URL, point the domain
Every migration method does these six steps. Step 5 is only needed when the address changes.

Before you start

  • Take a full backup of files and database and download it. See how to back up WordPress.
  • Lower your DNS TTL to 5 minutes (300 seconds) a day ahead, in your domain's DNS settings. Then the switch to the new host spreads in minutes instead of hours.
  • Do not cancel the old hosting until the new site has run cleanly for a few days.
  • Pause changes: no new posts, orders or comments during the move, or they will be missing on the new host.

Option 1: Let your new host or a plugin do it

Many hosts migrate WordPress sites for free when you sign up; ask first, it is the least work. Migration plugins such as Duplicator or All-in-One WP Migration package the site on the old host and unpack it on the new one. Watch for upload size limits on very large sites, and check the result with the list at the end of this guide either way.

Option 2: Migrate by hand

  1. Copy the files. Download wp-content and wp-config.php from the old host with SFTP. Install fresh WordPress on the new host, or copy the whole folder.
  2. Export the database. In phpMyAdmin on the old host: select the database, Export, Quick, SQL.
  3. Create a new empty database and user on the new host, then Import the .sql file into it.
  4. Update wp-config.php on the new host with the new DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. Keep $table_prefix the same as before.
  5. Test before switching DNS. Add a line to your computer's hosts file pointing your domain to the new server's IP, so only you see the new copy. Click around, then remove the line.

Changing the domain? Replace the old URL safely

WordPress stores your full address in the database: in settings, in every link and image inside your content, and in plugin settings. If the domain changes, all of those must change too.

The safe way is WP-CLI's search-replace, which most hosts provide over SSH. Always run it with --dry-run first. Here is the real dry run for moving our test site to a new domain:

Real wp search-replace dry run output: 432 replacements including 403 post GUIDs, and 29 replacements with GUIDs skipped
Real output from our test site. Skip the guid column: 29 real changes instead of 432.

Why you skip the GUID column

Each post has a GUID, a permanent ID that looks like a URL. Feed readers use it to know which posts they have already shown. WordPress's own documentation says not to change it, even when the domain changes. On our test site, 403 of the 432 matches were GUIDs, so --skip-columns=guid leaves the 29 that matter: links in content, six settings and one user profile.

Never use plain find-and-replace on the database

It is tempting to open the .sql file in a text editor, or run a REPLACE query in phpMyAdmin. Do not. WordPress and plugins store many settings as serialized data, where each piece of text is saved with its length. Change the text without changing the length and PHP can no longer read the setting.

Here is a real setting from our test site. The old address is 31 characters, the new one 29. We tested what PHP does with each version:

A serialized WordPress setting with s:31 before, a broken plain replace that keeps s:31, and the correct s:29, with PHP unserialize returning false for the broken one
A plain replace keeps the old length, and PHP returns false. That plugin's settings would silently reset.

No SSH? Use a search-replace plugin

If your host has no WP-CLI, install a search-replace plugin that handles serialized data (Better Search Replace is a common free one), run a dry run, apply it, then remove the plugin. Afterwards go to Settings, then General and check that WordPress Address and Site Address show the new domain.

Point your domain and check everything

Once the new copy works, change your domain's A record (or nameservers) to the new host. With a low TTL most visitors reach the new server within minutes; some networks take up to a day or two. Then work through this list:

Checklist after a WordPress migration: pages, images, wp-admin and permalinks, forms and emails, SSL, search engine visibility, redirects, Search Console
The checks that catch nearly every migration problem.

If the domain changed: keep your rankings

  • Redirect every old URL to the same path on the new domain with a 301, set at the server or host level on the old domain. See how 301 redirects work.
  • Add the new domain to Google Search Console, submit its sitemap, and use the Change of Address tool in the old property's settings.
  • Keep the old domain registered and redirecting for at least a year.

Migrate with your AI and wptaskify

If both the old and new sites are connected to wptaskify with the Pro add-on, migrate_site does steps 1 to 4 for you: it takes a full backup on the old site, makes temporary download links, has the new site pull the files server to server, and restores them. Because it overwrites the target, the AI must confirm both sites with you first. It does not change URLs, so if the domain changes you still run the search-replace above. The old site must be reachable on the internet, so a copy on your own computer cannot be pushed to a live host this way; use a backup and upload instead.

Example conversation: the AI confirms source and target, then runs migrate_site and reminds the user to replace the old URL
An example conversation using the real migrate_site tool.

Common migration problems

  • "Error establishing a database connection": the details in wp-config.php do not match the new database.
  • Redirected back to the old domain: the siteurl and home settings still hold the old address.
  • Pages 404 but the home page works: re-save Settings, then Permalinks.
  • Blank page: a PHP version difference or a broken file; see the white screen of death guide.
  • Images missing: uploads were not copied, or content still points at the old domain.

Frequently asked questions

How long does it take to migrate a WordPress site?

For a small site, about an hour of work plus DNS time. Large sites with many images take longer to copy. DNS changes usually reach most visitors within minutes to hours if you lowered the TTL first.

Can I migrate WordPress without a plugin?

Yes. Copy the files with SFTP, export and import the database with phpMyAdmin, update wp-config.php, and use WP-CLI search-replace if the domain changes.

Will migrating my WordPress site affect SEO?

Not if the URLs stay the same and the site works on the new host. If the domain changes, use 301 redirects and Google Search Console's Change of Address tool.

Why not just find and replace the old URL in the SQL file?

Because serialized settings store each text's length. A plain replace leaves the old length, PHP cannot read the setting, and the plugin falls back to defaults. Use WP-CLI search-replace or a serialization-aware plugin.

Should I change the GUIDs when moving to a new domain?

No. WordPress recommends leaving GUIDs alone. Use --skip-columns=guid with WP-CLI search-replace.

Move a WordPress site between hosts with your AIBring your own Claude or ChatGPT. Nothing goes live without your approval.
Get started free

Your AI is ready to work.

Connect WPTaskify and turn conversations into real actions.

Start Free