How To Migrate Your WordPress Website From One Host To Another?
Migrating a WordPress site to a new host can be a very time-consuming process for all the beginners. There are many WordPress site owners who are facing different sorts of problems with their current host and thus, they want to migrate it to a more reliable and performance optimized host. But the difficulties and complexities available in WordPress migration process make it challenging for people to start up the process.
If you are also struggling with the same situation, then you should read this blog post. Today, we will show you how to move a WordPress site from one host to another.
Step 1: Create a Backup of Your WordPress Site’s Files
Before migrating your website to the new host, make sure that you create a backup of all your database files and content files. Most of the site owners overlook this step and then struggle through out the WordPress migration journey.
Fortunately, WordPress offers several backup plugins such as BackUpWordPress that creates automatic backups of your site on a regular basis. You can also manually backup your site. For that, you’ll need to connect your web host → copy all files under the site’s directory and paste them on your local computer using an FTP program (like FileZilla).
Note: Since your .htaccess file is set to be hidden, ask your FTP program to display all the hidden files. This will display your .htaccess file as well.
Step 2: Export Your WordPress Database
After backing up your website, you will need to export all your WordPress database. All you need to do is to:
- Login your cPanel account
- Open ‘phpMyAdmin‘ application
- Select the database containing your WP installation
- Click on the Export tab lying on the navigation menu.
Make sure the format is set to SQL and export to Quick before clicking on the Go button. This will start exporting your database and download the file on your local computer.
Step 3: Creating a WordPress Database to Your New Host
Before migrating your WordPress site, you will need to create a database to your new web host. This will make it easy for you to import all of your SQL data into it – this simply sets a WordPress installation environment for you.
For that, you’ll need to login to your new host using the user details provided by them. This will connect you to the cPanel software. You can use the MySQL Databases application to create new databases.
Note: You should contact the support team of your web host if they are not providing you the application for creating new databases.
Create a database to your new hosting by following these steps:
- Access MySQL Database
- Create a new database using the relevant name for your site
- Create a new MySQL user, along with strong and secure password
- Include this user account to the new database and don’t forget to grand it All Privileges.
Tip: Note down the database name, the new MySQL username and its password in a secure place.
Step 4: Edit Your wp-config.php File
Once creating your WordPress database to your new host, the next step is to browse the folder that you downloaded on your local computer. In that folder, you will see a file named ‘wp-config.php‘ that access both your WordPress and database.
Create a copy of this file and save it on your local computer – this keeps your ‘wp-config.php‘ file safe so that you can instantly restore the changes if something goes wrong.
Now open the original version of this file in the text editor and make the following changes:
(a) Tweak the database name with a new one
Search the following line in your wp-config.php file:
define(‘DB_NAME’, ‘db-name’);
Since the ‘db-name‘ is your old database name, you will need to change it with the new one that you’ve just created.
(b) Tweak the database username
Look for the following line:
define(‘DB_USER’, ‘db-user’);
Just like the database name, you will have tweak the ‘db-user‘ with the new one.
(c) Tweak the database user password
Search and edit the following line:
define(‘DB_Password’, ‘xyz’);
As the database user password mentioned in the above line is from your old host, you will need to change it to the new secure password that you have created for your MySQL user.
Tip: Don’t forget to save the changes that you’ve made in your wp-config.php file.
Step 5: Import Your WordPress Database
This step is all about importing WordPress database to the new database you created on your new web host.
The process is simple. You’ll need to access phpMyAdmin from the cPanel on your new server. Now, choose the new database from the sidebar placed on the left side of your screen. After that, you will need to select the ‘Import’ tab from your navigation menu.
Click the ‘Choose File‘ button and select the SQL file under your ‘File to Import’ section. Make sure you un-tick the ‘Partial Import‘ check box, set the format to SQL before clicking the ‘Go’ button. The process of importing database will begin now.
Step 6: Upload Your WordPress Files
Once after importing your WordPress database, it’s the right time to upload your site’s file to your new web host. For that, you’ll need to connect to your new host using the FTP program.
Now browse to the folder to upload all of your WordPress files. If this is the only site being installed on this particular web server, then upload the files to the public_html folder is the usual directory.
Once selecting the remote directory, you can upload all your website file to the new host. This process can take some time to complete.
Tip: Never delete these files from your local computer.
Step 7: Link to Your New URL and Also Define Your New Domain
The problem occurs when the URL redirects you to the old web host and you will see a 404 error page. It happens because the domain name still points your old web host, which means if you use the domain name, all your files will be transferred to the old host instead of the new host.
So if you want to look for any instances of your old domain name, you will need to tweak it with the new name using Search Replace DB Script. This will let you change your old domain name with the new one quickly and easily.
Once you are ready with your new domain name, you will also need to change the site_url and home_url in the database so that you won’t redirect to the old domain whenever you login to your site.
Step 8: Update Your Domain Nameservers
Before running your WordPress site on your new host, make sure you reconfigure your domain’s DNS settings. Since they are set to point to your old host, you will need to point to the new server IP address. This means you will need to update your domain by tweaking your DNS nameservers.
Note: You can easily migrate your site to the new host if you’ve already registered your domain with your hosting company. But, if you are using domain registrar, you will need to change your nameservers. The process will take 48 hours to fully propagate.
Conclusion
All the steps mentioned above in this blog post will help you move your WordPress site to the new host quickly and easily. All you need to consider is that your new host is reliable and secure.
Save yourself some time, try All-in-One WP Migration https://wordpress.org/plugins/all-in-one-wp-migration/