Understand The Process of Migrating WordPress Site To another Domain
While playing around a WordPress powered website, there are times when you feel the need to move your website to a new host or domain. The reason could be anything- you might get tired of the sluggish performance and awful support of your existing web host, your site might risks the downtime, data loss or anything that matters. There are many reasons for migrating WordPress site.
Migrations can be challenging as you risk messing things up. But this is something which can be achieved very easily if you follow this tutorial, which I have compiled for you. The tutorial will explain you the entire process of migrate wordpress to another domain. Just follow it, save the hassle and reduce the amount of time it takes to transfer your website.
So, let’s learn through the steps you need to take to make a move from one host to another.
1. Create a Back Up of your WordPress webiste
The very first step you need to take is just create a back up of your website. Backup is essential as you can get your website back if anything goes wrong. The backup should include all your theme files, plugins you use, your uploads, and database.
There are many plugins out there that help you backup your complete site. You can use any tool you are most comfortable with, such as BackUp WordPress, BackwpUp etc. You may also choose to copy all the files from your local computer manually using an FTP program (such as FileZilla) and then upload them to a new location. While doing so make sure you copy any hidden files such as .Htaccess. For this, you can take the help of your FTP program so that hidden files can be displayed properly.
The process could take some time depending upon the number of media you’ve uploaded on your website.
2. Exporting the WordPress Database
It’s a short and simple process. All you need is just sign up to the cPanel account of your web server and click the phpMyAdmin icon under the database heading. Select the database your website is working with in the left menu, and then click on the ‘Export’ in the top menu.
Under the Export tab, there is a default settings called ‘Quick’ export and the SQL format, make sure you’ve selected both of them to smoothly export your WordPress database. Now, hit the ‘Go’ button to kick start the exporting process. While doing so, a file will be downloaded to your computer. You’ll be prompted to either open or save the file. Save it to a convenient location. Congrats! You have successfully exported your database.
3. Creating the WordPress Database on the New Host Server
Before we actually start migrating our WordPress site, let’s create an environment for the WordPress installation. The process can be done by creating a database which can be used for importing the SQL data.
The process is simple. Just login to your new web host. Enter the provided details and connect with the cPanel software. Here, we will be using MySQL Databases application. For those who don’t have this application running, it is recommended to contact your web host and take the necessary help to generate a new database.
Following are the steps you need to take to create a new database:
- Go to MySQL database and start creating a new name provided by a suitable name.
- Now you need to assign a new user name to it along with a secure password.
- Make sure you write the database name, user name, and the password you’ve recently created.
- Now, link this new account with the new database. While doing so, you’ll be prompted to grant new privileges. Make sure you select “All Privileges” and then select the “Make Changes” button.
4. Modify wp-config.php File
Once you are done creating the new database, next move on to edit the wp-config.php file, which is the WordPress configuration file.
Copy this file and save it at a secure location on your local computer. It’s a good idea to make a copy of this file because if anything goes wrong, you’ll still have a fully functional website running somewhere.
Now, open the file and start making the following changes with the help of your chosen text editor.
Alter the database name
Look for the line,
/** The name of the database for WordPress */ define('DB_NAME', 'db_name');
the db_name part of the line will be the new name of your database. You need to replace this line with the MySQL database name you have created in the previous step.
Change the database username
Locate the line,
/** MySQL database username */ define('DB_USER', 'db_user');
the db_user part of this line should be set with the username you’ve created.
Change the user password
Now, edit the line,
/** MySQL database password */ define('DB_PASSWORD', 'db_password');
change the ‘db_pass’ section with the password you’ve created for your MySQL user.
Save wp-config.php file and close it.
You have successfully set up the configuration file; however, it still does not include any database tables. So, to fix it, the information must be imported to the database.
5. Importing WP to The New Database
You can use PHPMyAdmin to import your database. It’s a simple process, just follow the below mentioned steps:
- Login in to phpMyAdmin and select the database you want to import the information;
- Select the ‘import’ tab at the top of the page;
- In the ‘file to import system’, select the SQL based file you want to export;
- Skip ‘Partial Import’. It is made for situations when want to skip a set number of code rows;
- Click on “Go”.
After some time, you’ll get a configuration message that you have imported the file successfully. The process might take some time, depending upon the size of the imported file.
6. Upload WordPress Files to the New Server
As of now, we have successfully created a new database and configured wp-cofig.php file, now, it’s time to upload your website files to the newly created server. The process is easy. Just login to your site using FTP and look for the location where you want to copy your website. If you want your website to be held in the root directory, copy your files to the public_html folder.
As you have selected the remote directory, you can start uploading the website files. This could be a bit lengthy process. So, be patient.
Also, make sure you don’t delete these files from your local computer once the process completes. You’ll need them in the final step.
7. Editing Database
For people who have added links or inserted images to other parts of their website, often face the problem relating to the URL breaks when migrating to a new domain. Fortunately, this can be fixed easily by updating the database.
Log into phpMyAdmin panel and use the code below to swap old and new URLs, no trailing slashes. Also if necessary change the table prefix values where applicable (ie wp_ ).
UPDATE wp_options SET option_value = replace(option_value, 'https://www.oldurl', 'https://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'https://www.oldurl','https://www.newurl'); UPDATE wp_posts SET post_content = replace(post_content, 'https://www.oldurl', 'https://www.newurl'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://www.oldurl','https://www.newurl');
We don’t advice you to randomly open your database and editing it manually as it might damage the serialized data. There is a script available called Search Replace DB that helps you perform this task. The script comes with some PHP strings which help you to perform search and replace related actions.
8. Configure the DNS Settings
This is the final step you need to take before your site actually runs on the new host. Here, you need to configure your DNS settings. Just login to the site hosting your domain and point it to the new host name you are using now.
The process depends on host to host so we advice you to contact your service provider to know more about this step.
After changing your DNS settings ( the process might take up to 48 hours to fully propagate), login to your WordPress site on the new server using the details (username and passwords) and check whether everything is running properly.
Conclusion of Migrate WordPress to another Domain is only one:
Migrating WordPress site to a new host isn’t an uphill battle if steps are followed wisely. Hopefully, you enjoyed reading the tutorial and be sure to bookmark it for the future reference.