Manually migrate WordPress to DreamHost

Overview

You can now migrate your own WordPress site to DreamHost for free, using the DreamHost Automated Migration Plugin. The plugin can be used on any DreamHost account with an active hosting plan. See the following article for more details:

If you are having trouble migrating your website from another host, or just don't have the time, DreamHost currently offers a service that takes care of that for you. You can find more information in the DreamHost Website migration services article.

This article describes how to move your WordPress site from your current host to DreamHost.

If you're moving your WordPress site from another DreamHost account, some additional steps are required to ensure that additional items (such as email) are moved correctly. See the following article for further details:

If you're moving from WordPress.com, then use the following WordPress instructions for further details:

When you create a backup of your website hosted at Wordpress.com, the exported site is in XML format. Only posts, pages, comments, categories, and tags can be exported. Themes and widgets cannot be exported. If you need to export your database, it needs to be exported separately. See the following article for further details:

Backing up your data

Before making any changes to your website, DreamHost highly recommends backing up your database. Instructions can be found in the following article:

However, you may need to contact your current host for instructions on how to export files from their system.

Step 1 — Preparation

Make sure you have the following items in order to successfully manually migrate your WordPress files to DreamHost:

  • You must at least save your wp-content folder and MySQL database. You do not have to include your .htaccess and wp-config.php unless you have custom coding within these files. DreamHost recommends using the latest WordPress core files.
  • Before you start uploading your content, please be sure that your domain is fully hosted and has WordPress installed. DreamHost recommends using the One-Click Installer or purchasing a DreamPress plan to have the WordPress core files installed automatically.

The default web directory is located in the following path, which is where you should upload your content:

/home/user/yourdomain.com

If you’re using Shared Hosting, VPS, or a Dedicated server, please make sure you know where your web directory resides. DreamHost recommends using a FTP client to upload your content but you can also use WebFTP if your files are smaller than 1GB.

Step 2 — Uploading your files to DreamHost

After you set up a new WordPress install at DreamHost, you are now ready to upload your saved content that is described in the previous section.

The following image shows an example WebFTP file directory in a domain folder named "exampledreamhost.com". Upload your files to the domain folder of your WordPress site. You can also delete the "wp-content" folder since there is no content within it:

manually-migrate-wp-01.png

The following shows you the two files after you upload them, "example-backup.sql" and "wp-content.zip":

manually-migrate-wp-02.png

You can unzip the "wp-content.zip" file by right-clicking on the file and selecting 'extract'. If you’re using SSH to extract your files instead, you can instead use the following command:

[server]$ unzip  wp-content.zip

Step 3 — Importing your content

Since you now have your backed-up SQL file uploaded to your domain directory, all you need to do now is reset your new database and import your backed-up database. Resetting your database simply means removing all tables from the database so that you have a blank database to import your SQL file into.

There are two methods to clear out your current database, which are described in the following sections:

  • Using phpMyAdmin (simple, limited to 200MB)
  • Using SSH via wp-cli commands (more advanced)

phpMyAdmin

To clear your current database using phpMyAdmin:

  1. See the following article to learn more about how to login to phpMyAdmin:
  2. After you login to phpMyAdmin, highlight all of your tables:
    manually-migrate-wp-03.png
  3. After you highlight all of your tables, select the 'drop tables' option in the dropdown at the bottom and then click OK. Make sure the table is cleared.
    manually-migrate-wp-03.png
  4. Click the 'Import' tab at the top to upload your SQL file.
    manually-migrate-wp-04.png
  5. Click the Choose File button, select your SQL file, and then allow it to upload.
  6. Verify that your tables are correct. You can make any updates to the wp-config.php file such as your adjusting the prefix tables if needed.

SSH via wp-cli commands

If you prefer not use phpMyAdmin, you can instead upload your SQL file using wp-cli commands via SSH.

In the following directory-listing example, you can see that the SQL table "example-backup.sql" has already been uploaded:

[server]$ ls
example-backup.sql  license.txt      wp-admin		   wp-config.php   wp-includes	      wp-mail.php	xmlrpc.php
favicon.gif	    quickstart.html  wp-blog-header.php    wp-content	   wp-links-opml.php  wp-settings.php
favicon.ico	    readme.html      wp-comments-post.php  wp-content.zip  wp-load.php	      wp-signup.php
index.php	    wp-activate.php  wp-config-sample.php  wp-cron.php	   wp-login.php       wp-trackback.php

Run the following command, which removes your current tables:

[server]$ wp db reset
Are you sure you want to reset the 'example_dreamhost' database? [y/n] y
Success: Database reset.

After the reset completes, run the following command to import the backup (be sure to replace 'filename.sql' with the actual file name of your backed-up database):

[server]$ wp db import filename.sql
Success: Imported from 'example-backup.sql'.

That should complete the import of your database. Large files may take longer but you will received a confirmation when the import completes. Make sure your wp-config.php prefix settings are correct and that your site is live.

What if I migrate my domain to a different URL?

The example above shows a domain using the same URL from an old host that is imported to DreamHost. If you're moving your site to a new domain name during your migration, the above steps are the same, but include one extra step. You must update your 'Home' and 'Site URL' as well as your database URLs within the imported database.

There are several ways to do this, which are described below. If you plan to use a plugin to help replace your database URLs, you can use a plugin called "Better Search Replace" (described below) or "Velvet Blues". If you plan to use SSH instead, wp-cli includes Better Search Replace functionality.

Updating your 'Home' and 'Site URL' through wp-admin

Make sure you have a backup of your SQL file. If you make a mistake in the following steps, it may be difficult to fix within a live site.

You can update your Home (Wordpress Address URL) and Site URL (Site Address URL) through the wp-admin page. Go to Settings > General:

manually-migrate-wp-05.png

The following shows how to update database URLs using the "Better Search Replace” plugin:

manually-migrate-wp-06.png

In this example, the following change is made:

  • Old URL: http://www.exampledreamhost.com/
  • New URL: https://exampledreamhost.com/

Run the search-replace tool, which replaces your old URLs with the new one.

Updating your 'Home' and 'Site URL' through SSH

Make sure you have a backup of your SQL file. If you make a mistake in the following steps, it may be difficult to fix within a live site.

You can also use wp-cli commands through SSH to update the URL values. Make sure you're in the domain directory for WordPress:

[server]$ pwd
/home/wp/exampledreamhost.com

Run the following command, which makes a backup to your user directory:

[server]$ wp db export ~/backup`date +"%d-%m-%Y"-%T`.sql

Run the following commands before updating your Home/SiteURL to make sure they're properly pointed:

[server]$ wp option get home
http://www.exampledreamhost.com
[server]$ wp option get siteurl
http://www.exampledreamhost.com/

You can see from the above example URL that the old location is used (http://www.exampledreamhost.com). You can now update the URLs so that it points to 'https://exampledreamhost.com' instead.

  • Old URL: http://www.exampledreamhost.com
  • New URL: https://exampledreamhost.com

Run the following commands to update the WordPress (home) and Site Address (siteurl):

[server]$ wp option update home 'https://exampledreamhost.com'
Success: Updated 'home' option.
[server]$ wp option update siteurl 'https://exampledreamhost.com'
Success: Updated 'siteurl' option.

Run the following command after you update the Home/SiteURL to update the remaining database URLs:

[server]$ wp search-replace 'oldurl.tld/' 'newurl.tld/'

As an extra verification step, you can add the dry-run flag. Make sure there are two small dashes (--) when using this flag; i.e., --dry-run, which performs a command without making any changes. Verify that it is replacing the old URL with the new one.

Another tool you can use is the --all-tables-with-prefix flag, which ensures the change is applied to all of the tables.

For example:

[server]$ wp search-replace 'http://www.exampledreamhost.com/' 'https://exampledreamhost.com/' --all-tables-with-prefix --dry-run
Success: 5 replacements to be made.

The above response confirms that there are replacements to be made. When you’re ready to run the command, make sure to remove the --dry-run flag:

[server]$ wp search-replace 'http://www.exampledreamhost.com/' 'https://exampledreamhost.com/' --all-tables-with-prefix
Success: Made 5 replacements.

After you complete the search-replace function, be sure to run the following command to clear any cache:

[server]$ wp cache flush
Success: The cache was flushed.
The wp cache flush command clears any cache that results from the search-replace functions.

Viewing your site and updating DNS

If your DNS is not pointed to DreamHost, view the following article to view your site using a hosts file.

If the site appears as it should, you are ready to point your DNS to Dreamhost.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?