If you are planning to migrate your website from one hosting provider to another because you are not happy with your current provider, then welcome! You are at the right place.
Most of the people plan to move their websites to another hosting company because of the issues like load time, data storage and cost. And these are the good reasons to shift your website to a new host. In this article, we will discuss how to migrate a website from one host to another.
- Moving the website’s files.
- Moving the website’s database(s) (if any).
- Configuring your application to work at the new host.
- Pointing your domain’s DNS to the new host.
Now here, one must be familiar that when you transfer your WordPress website to a new hosting company, there can occur two major risks and those are data loss and downtime. Both of these prospects can temporarily make your website unavailable to users and search engine that eventually results in loss of clients or sales and google ranking. So you must make sure to choose the best hosting company that will take care of it all.
How to Migrate a Website?
We have divided the article into different steps for the ease of our readers. After going through a step-by-step process to migrate your website, you will have a better idea of the complete process.
Backup Website Files
The most absolute step of any plan is backup, so in the case of shifting your website. There are many plugins available to fully backup your site but the most suitable way of transferring your website files to a new web hosting company is via File Transfer Protocol (FTP). The FTP program will connect to your new provider and copy all files under your website’s record to a folder on your computer.The time it takes depends on the size of the media you have uploaded to your site.
Export the WordPress Database
Exporting your database is an easy step that only needs a few levels to finish. Login to the cPanel account of your web server and open the phpMyAdmin application. Select the database that includes your WordPress installation from the menu on the left-hand sidebar and once selected click on the Export tab on the navigation menu.
The default settings of a Quick export and the SQL format for the export are enough for what we require. Click the Go button and the database export process will start and a file will be saved to your computer. Once the database export and the FTP transfer of your files have both finished, you are all set to jump onto the next step.
Create the Database on New Server
At this stage, you have to create a database so that you can import your SQL data into it. After creating, log in to your new web host with the user details they have provided you and connect to the cPanel software. We are using the MySQL Databases application as an illustration. If your web host doesn’t have that application running then you should contact their technical support team to find their process of creating new databases.The steps for creating a database are easy and are as follow:
- Open MySQL Database and create a new database with a suitable name for your website.
- Create a new MySQL user (with a strong password).
- Add this user account to the new database and allow it All Privileges.
Write down the database name, the new MySQL username, and its password. You will need them onwards.Edit wp-config.php File
Open the folder on your computer where you saved your website files to. In that folder, there is a file named “wp-config.php” that manages the access between WordPress and your database.
Get a copy of this file and store it in a different folder on your computer. This is important for restoring the changes we are about to make should something go wrong later.
Open the original version of the file with your preferred text editor and create the following three settings:
- Change the Database Name
Find the following line:
The db_name part of this line will currently be fixed to the MySQL database name of your previous web host. This must be changed to the name of the new database you have just created.
- Change the Database Username
Below this you will see the line:
In this line, you have to change the db_user part from the username of your previous host to match the new username you have just created.
- Change the Database Password
Lastly, edit the third line:
As with the others, the db_pass segment of this line must be changed to the new protected password you created for your MySQL user. Save wp-config.php and close the file.
Import Your Database
So now you have a new database and can begin the import process. Launch phpMyAdmin from the cPanel software on your new server and pick your new database from the list on the left-hand sidebar. Once it opens select the Import tab from the navigation menu.In the File to Import section click the Choose File button and select the SQL file you exported earlier.
Un-check the Partial Import checkbox, make sure the format is set to SQL and then click the Go button. The database import will now start.The time this import takes differs depending on the size of your database. You should get a message notifying you of the completion of the import when it has ended.
Upload the Files to New Host
At this stage, you have successfully created the database and have reconfigured the settings. It’s time to upload your website’s files now.
Connect to your new web host using your FTP program and browse to the folder that your website is going to be kept. If this is the primary or only site being installed on this web server then uploading the files to the public_html folder is the usual directory. With the remote directory selected you can upload your website files that should now include the updated version of wp-config.php. As with the previous download, this step can take some time.Don’t delete these files from your computer once the upload completes. They are still required until the last steps have been achieved.
Last but Not Least
Before you can access the website on your new host you have to reconfigure your domain’s DNS settings. They will be set to point to your previous host and you have to point the right records to the new server IP address.
DNS changes normally take 48 hours to propagate and the best approach to do this is when your traffic is minimum. During the process, avoid making changes on the website as you may change the old version of the site.
After the 48 hours when you finish the process, you can access the new web host and this is the right time to connect to your previous web host and delete the files and database.