• Facebook Icon Link
    • Instagram Icon Link

    How to Migrate a WordPress Site.


    how to migrate a wordpress site

    Tutorial Overview.

    This tutorial will explain how to migrate a WordPress website from one host to another, how to download and upload a WordPress site via FTP, how to create a MySQL database, how to add a user to the database, how to import and export a MySQL database, how to connect the website to the database and the steps to follow if you are moving to a new domain name.

    Quickies.

    How to Migrate a WordPress Website to a New Host.

    Here are a few definitions to make this process easier:

    • WebsiteA – The website that is being moved.
    • DatabaseA – The database that is being moved.
    • ServerA – The server that the website is being moved from.
    • WebsiteB – The website being replaced (if applicable).
    • DatabaseB – The new database.
    • ServerB – The new server or hosting service that the site is being moved to.

    A server is a device that your hosting service uses to store your website files. In this tutorial, when I use the word “server” I am referring to your hosting plan.

    A Brief Overview of How to Migrate a WordPress Website.

    1. Download WordPress files from ServerA to your desktop.
    2. Export the MySQL database from ServerA to your desktop.
    3. Create a new MySQL database in cPanel on ServerB.
    4. Import DatabaseA into DatabaseB.
    5. Upload the WebsiteA files to ServerB.
    6. Connect WebsiteA to the database.

    Divi WordPress Theme Banner

    How to Download a WordPress Website via FTP.

    1. Create an empty folder on your computer desktop to store WebsiteA in.
    2. Make an FTP connection to ServerA. If you are unsure how to do this, check out this tutorial: How to Create an FTP Account in cPanel.
    3. Navigate to the directory that WebsiteA is in.
    4. Select all of the folders that make up WebsiteA.

    This is what a standard set of WordPress files and folders look like.
    migrate wordpress website instructions

    1. Download all of these files into the folder you created on your desktop.
    2. We’ll come back to this later.
    3. Next: Export a copy of DatabaseA.

    How to Export a MySQL Database.

    1. Login to cPanel or the hosting account of WebsiteA and go to the cPanel.
    2. Once you are in cPanel, click on phpMyAdmin.

    cpanel php myadmin

    1. In the left side panel, click on the database that WebsiteA is connected to.

    mysql database

    If there is more than one database and you are not sure which one is the right one:

    • Open the folder that contains the files from WebsiteA that you just downloaded.
    • Open the wp-config.php file in a text editor.
    • Look for the line of code that looks like this: define( ‘DB_NAME’, ‘database3’ );
    • database3 is the name of the database.
    1. Click on the correct database in the left side panel of cPanel.
    2. Click on Export.

    export database

    1. Set Export Method: to Quick and Format: to SQL.
    2. Click on Go.

    mysql export method

    1. This will download DatabaseA. We’ll come back to this later.
    2. Next: Create DatabaseB on ServerB. (the new server)

    How to Create a MySQL Database in cPanel.

    1. Login to cPanel or the hosting account of WebsiteB.
    2. Once you are in cPanel, click on MySQL® Databases.

    cpanel php myadmin

    1. Enter a name for DatabaseB in the New Database field.
    2. Click Create Database.

    create new database cpanel

    This name must be unique. If you are on a shared hosting plan and someone is already using the database name you want, you will get a warning to choose a different name.

    1. Once DatabaseB is created click Go Back.
    2. Now we need to create a user to pair with DatabaseB.
    3. Enter a Username and generate a Password and keep this information in a place you will remember.

    add new mysql user

    1. Click on Create User.

    create new mysql user

    1. Click on Go Back.
    2. Next: Add this user to DatabaseB.

    SiteGround WordPress Hosting Banner

    How to Add a User to a Database in cPanel.

    1. Scroll to the section labeled Add User To Database.
    2. In the User field select the user you just created.
    3. In the Database field select DatabaseB. (the database you just created)

    add user to database

    1. Click on Add.
    2. On the next screen we will set the user privileges for DatabaseB.
    3. At the top of the page select All Privileges.
    4. Click on Make Changes.

    select database privileges

    1. Click Go Back.
    2. Next: Import DatabaseA into DatabaseB.

    How to Import a MySQL Database in cPanel.

    1. Login to cPanel if you are not already.
    2. Once you are in cPanel, click on phpMyAdmin.

    cpanel php myadmin

    1. In the left side panel, click on DatabaseB. (the new database)
    2. Click on Import.

    import mysql database

    1. Click on Choose File and upload DatabaseA.

    database import screen

    1. Click on Go.
    2. If everything goes well, you will get a success message.

    sql upload

    If you are replacing an existing website (WebsiteB), you will need to remove it from the server before uploading WebsiteA. If you need to retain a copy of WebsiteB, you can follow the directions here. Then you can delete WebsiteB from ServerB.

    1. Next: Upload WebsiteA to ServerB.

    How to Upload WordPress Website Files via FTP.

    1. Make an FTP connection to ServerB. If you are unsure how to do this, check out this tutorial: How to Create an FTP Account in cPanel.
    2. Navigate to the directory that WebsiteA is going in.
    3. Upload all of the files from WebsiteA into this directory.
    4. Next: Connect WebsiteA to the database.

    How to Connect a WordPress Website to a MySQL Database.

    1. If you are not already connected, make an FTP connection to ServerB. If you are unsure how to do this, check out this tutorial: How to Create an FTP Account in cPanel.
    2. Navigate to the directory that WebsiteA is in.
    3. Locate the wp-config.php file in the root directory of the website.
    4. Open this file in a text editor.

    wordpress wp-config file

    The next couple steps will use the username and password we created in this section.

    1. Replace database_name_here next to DB_NAME to the name of the database.
    2. Replace username_here next to DB_USER to your username.
    3. Replace password_here next to DB_PASSWORD to your password.
    4. Save the file.
    5. Enter the URL in a browser and view the website.

    How to Migrate a WordPress Website to a Different URL?

    If you are moving a WordPress site to a different URL there are a few additional things you need to do to make things work correctly.

    Database Edits.

    After you import the database to the new server:

    1. If you are not already there, login to cPanel and go to phpMyAdmin.

    php myadmin in cpanel

    1. Click on the database name in the left side panel.

    mysql database names

    1. Click on wp_options.

    database tables

    1. Locate the siteurl in the option_name column.
    2. Click on Edit on the left of the siteurl row.

    wordpress wp options table

    1. In the option_value field, change the URL to the new URL.
    2. Click on Go in the lower right.

    wordpress option value

    1. Repeat these steps for the home row.

    To recap, you shoud have changed two rows in the wp_options table, the siteurl row and the home row, to the new URL. These rows are usually number 1 and 2.

    1. Login to the admin area of the website.
    2. In the admin sidebar, under Settings, click on Permalinks.

    wordpress permalinks

    1. Scroll to the bottom of the page and click on Save Changes.

    This will reset all of the permalinks on the website.

    1. Next: Use search and replace to change all of the old URLs.

    SiteGround Web Hosting Banner

    How to Edit all WordPress URLs with Search and Replace.

    There are still going to be old URLs in the database so we need to change them to the new URL. I have always used the Better Search Replace plugin for this. There are many plugins out there that will work just fine, this just happens to be the one I use.

    better search replace plugin

    1. Download and activate the Better Search Replace plugin. If you are unsure how to do this, check out this tutorial: How to Install a WordPress Plugin.
    2. In the admin sidebar, under Tools, click on Better Search Replace.

    better search replace menu item

    1. Enter the old URL in the Search For field.
    2. Enter the new URL in the Replace With field.

    better search replace interface

    Warning: This action modifies the database and is irreversible. Take a backup of the database before running this action.

    1. In the Select Tables box, select all of the tables.
    2. You will notice that the Run as a dry run? box is selected by default. As long as this is selected it will not make any chages to the database.
    3. When you are ready, un-select the Run as a dry run? box and click Run Search/Replace.
    4. There might be URLs hard coded into your WordPress files. If this is the case you will need to find them and change these as well.

    If you need assistance to migrate a WordPress website, please contact us at 2640media.com. We will be glad to help!

    Check out my other tutorials and reviews @ TwentySixForty.

     

    Additional Posts.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Pin It on Pinterest

    Share This