A different web hosting provider offers different service quality. As a user, you definitely want to use a hosting provider that offers the best quality such as Kinsta, WP Engine, to Pressable. It’s not a problem to jump from a web hosting provider to another one only to try its service quality. This article will show you how to migrate a WordPress site to a new hosting. Be it a premium WordPress hosting or a traditional shared hosting.
Technically, moving a WordPress site to new hosting is not a hard job. You just need to be a little thorough. The main step you are going to do is move all of the files under the root directory of your WordPress site from your old hosting to the new hosting. But first, you need to edit the DNS of your domain to point it to the new server (hosting) you want to migrate to.
Step 1: Edit the DNS
Before starting to move your WordPress files, you need to edit the DNS of your domain to point your domain to the new hosting you want to switch to. You can edit the DNS from the client area of the domain provider you bought the domain from. Manage the domain by clicking the wrench icon.
Edit the DNS by clicking Nameservers on the left panel. Enter the nameservers of your new hosting to the fields. If you have no idea about the nameservers, you can ask the customer service/technical support of your new hosting provider. Click the Update Nameservers to update your nameservers.
Step 2: Add a New Domain to Your New Hosting
Once done setting the nameservers, the next step you need to do is add your domain to your new hosting. Make sure that the domain name you add is the domain of the website you want to move to. The method of adding a new domain can vary, depending on the control panel offered by your hosting provider. In this example, the control panel we use is cPanel.
To add a new domain in cPanel, click Add Domains on the DOMAINS section.
Enter your domain name on the available field and click the Add Domain button. There is also an option to create an FTP account for your domain in case you need it.
Step 3: Download the WordPress files from your old hosting
Once done adding your domain to your new hosting, you can download the files of your WordPress site. The files you need to download are all of the files (including folders) under the root directory of your WordPress installation.
To ease your job in downloading the files, you can gather all of the files in a new folder and create a ZIP file from the folder and download the ZIP file using an FTP client.
Step 4: Upload the WordPress Files to Your New Hosting
Once the WordPress files are downloaded to your computer, upload them to your new hosting. Again, you can use an FTP client to ease your job. One thing, make sure to put the files on the root directory of your website (“public_html” in most cases).
Step 5: Export the WordPress Database Tables from Your old Hosting
The vast majority of web hosting providers offer phpMyAdmin to make it easy for users to manage databases. If your old web hosting provider also offers phpMyAdmin, you can use it to export the database tables of your website.
If you forgot the database name used on your website, you can find out on the wp-config.php file (visit this post to learn more).
To export the database tables using phpMyAdmin, launch phpMyAdmin. If you use cPanel, you can find it on the DATABASES section.
Find your database on the left panel and select (by clicking it). Click the Export tab, followed by the Go button.
Step 6: Create a New Database on Your New Hosting
You need to create a database to host the tables you exported from step 5 above. On cPanel, you can create a database by clicking MySQL Databases on the DATABASES section.
Enter your preferred database name on the available field on the Create New Database section and click the Create Database button.
Scroll down to the Add User To Database section and add a user for the database you have just created. You can either create a new user or use one of the existing users. Make sure to grant your database user All Privileges.
Step 7: Import the Tables to the New Database
On step 5, you have exported the database tables from your old hosting. Now, import those tables to the new database you have just created on step 6 above. To do so, launch phpMyAdmin on your new hosting and select the database you have just created on step 6 from the left panel (by clicking it). Click the Import tab and choose the SQL file of the database by clicking the Choose File button. Click the Go button to start importing.
Step 8: Edit the wp-config.php File
This is the final step. You need to edit the wp-config.php file to connect WordPress with your new database. There are lots of ways to edit this file. You can edit it directly from the control panel of your hosting or download it first and edit it on your local computer and re-upload the edited file.
The wp-config.php file itself is located under the root directory of WordPress. There are three components you need to edit:
- Database name
To change the database name, look for the following line
define( 'DB_NAME', 'database_name' )
Tailor “database_name” with the name of your new database.
- Database username
To change the database username, look for the following line
define( 'DB_USER', 'database_username' );
Tailor “database_username” with the username of your new database.
- Database password
To change the database password, look for the following line
define( 'DB_PASSWORD', 'your_database_password' );
Tailor “your_database_password” with the password of your new database.
If your database is located on a different server, you need to enter its address from the following line.
define( 'DB_HOST', 'localhost' );
Tailor “localhost” with the address of your database server.
Done! Your website has been migrated.
PS
A crucial thing to note. Make you sure to backup your WordPress files as well as the database before you perform the steps above just in case you make a mistake.
Once everything is done, you can use PING to check if your website has been pointed to the IP address of your new hosting. One thing. It usually takes up to 24 hours for a new DNS to fully propagate.