How to migrate your WordPress website quickly to a fresh Installation. - AREDCREATIVE

How to migrate your WordPress website quickly to a fresh Installation.

There can be a variety of reasons why you may need to migrate your WordPress website. You could be changing domains, changing your hosting provider, or needing a fresh WordPress installation after some website issues.

Below we will give you a walkthrough of one of the quickest ways for WordPress migration to a fresh installation.

Before we begin, make sure to do a complete backup of your website. Both the folder on your server which holds your WordPress installation and the database connected to your website. Once complete you are ready to get started with the Migration process.

For the sake of this tutorial, we will be performing a Migration to a fresh WordPress installation with the same hosting service. Note: These steps for the most part are the same if you were to Migrate to a completely new hosting service.

Step 1: Download the latest version of WordPress.

This step is pretty simple. If you are using your hosting service’s Cpanel you can use the script installer to do so.
If you choose to go the manual route, visit the WordPress website to download a copy.

Step 2: Compress and Download the wp-content folder.

Login to your Cpanel account and head over to your file manager.
From within the file manager, look for the folder that is holding the WordPress installation of your current website.
Compress the wp-content folder and download it.
Keep a copy of that Zip file you just downloaded, we’ll need it again later.

Step 3: Export and Download Database

From within your Cpanel click on your Phpmy Admin icon to make changes in your databases.
Search for the name of the database connected to your current website. (You can find your Database name from the wp-config.php file found in your WordPress installations wp-content folder. see photo below.)

Your Database name and password as shown in your wp-config.php file.

Select the correct database and export the tables and download the file.

Once done, keep a copy of that database file on your desktop, we’ll need it for later.

Step 4: Delete the new wp-content folder and replace it with the old one.

Once you have your new WordPress installation setup you will need to delete its wp-content folder only.

Navigate to the new WordPress installation folder and delete the wp-content folder.

Once complete re-upload and extract the wp-content Zip folder from the old WordPress installation that you downloaded previously in step 2.

Step 5: Delete new database tables and import old database tables.

Now we’re going to import our old database tables to the new installation.

Navigate to your PHPMyadmin in your Cpanel and find the new database that was just created for the new WordPress install. (Remember you can find the database name on your WordPress installations wp-config.php file.)

Open the database and delete all the tables.

Once complete import the old database into the new database. (This is the database file you downloaded in step 3.)

Step 6: Change the database Prefix and update URLs.

In the final step of the migration, we’ll finish off from within the database.

We will need to make sure the database prefix matches the prefix showing in our new wp-config.php file.

Navigate to your wp-config.php file and scroll down until you see the prefix. (see picture below)

Your Database Table prefix is shown in your wp-config.php file.

The prefix shown in your wp-config.php file should be replaced with the prefix being used in the new database.

Next, we’ll make sure all the links are correct for the new website.

For this, we will need to use the following database query to make sure all likes are updated programmatically at once.

Copy and paste the MySql query below and perform launch it in the new database.

UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');

UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');

UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');

UPDATE wp_comments SET comment_content = replace(comment_content , 'Existing URL','New URL');

If you have images linked in your posts then you need to run the following additional queries.

For images that are inside posts

UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');

For images linked in the old link manager

UPDATE wp_links SET link_image = replace(link_image, 'Existing URL','New URL');

For images linked as attachments

UPDATE wp_posts SET guid = replace(guid, 'Existing URL','New URL');

Code credit: https://blog.templatetoaster.com/update-old-urls-in-database/

Once complete you are ready to visit your website at your new domain.

Just like that you’ve successfully migrated your website to a new domain on the same server.

Give this technique a try and let us know how it works for you.


Article by:
    Adrian Redmond
  • Front End Web Developer
Web Hosting Canada