Are you considering moving your WordPress site to a new hosting provider or server? While the process may seem intimidating, it doesn’t have to be. By following our straightforward guide, you can successfully migrate your WordPress site without any complications.
Many individuals are forced to switch hosts due to issues with their current provider. However, the fear of making a mistake and damaging their website(s) often leads to delaying the migration to a more reliable host.
Let’s walk through the steps involved in moving your WordPress website to a new host. Before we begin, remember that Upspeedhosting offers complimentary website migration services for customers who have purchased a yearly hosting plan from us. You can visit our shared hosting pricing page to acquire a plan.
1. Backup Your Website Files
Before embarking on the migration process, creating a comprehensive backup of your WordPress site is essential. This practice aligns with general WordPress security guidelines and is recommended prior to implementing any significant changes. Moreover, a thorough backup is crucial for a successful migration due to the significant amount of data involved.
So how do you back up your site? There are plenty of plugins you can use to backup WordPress for you. With a backup plugin you typically install and then use built-in settings to manage which files get backed up, how often and where your backups are stored.
If you want to use a plugin, one of the best options is Updraftplus. This plugin offers tons of powerful backup options for scheduling, restore points, limit files, filter large files, backup splitting, backup themes and plugins, remote storage compatibility, multisite support and more.
You can also manually create a backup using a file transfer tool (FTP) to access your website files. Popular FTP programs include FileZilla (PC) and Transmit (Mac). Once installed, use your SFTP credentials (provided by your web host) to connect to your website’s server. Select and download all files from your website’s directory, including the hidden .htaccess file. Consult your FTP program’s help file if you need to unhide this file.
While the file download is in progress, you can proceed to step two and create a copy of your database. The time it takes to download the files depends on the number of media files in your website.
2. Export the WordPress Database
Exporting your WordPress database is a straightforward task that can be accomplished in a few steps. Begin by accessing your web server’s cPanel account and launching the phpMyAdmin application. From the list on the left sidebar, locate and select the database associated with your WordPress installation. Next, click on the “Export” tab located in the navigation menu.
The default settings for a “Quick” export and the SQL format are suitable for our purposes. Simply click on the “Go” button to initiate the database export process. Once the export is complete, a file containing the exported database will be downloaded to your local computer.
After the database export and FTP transfer of your files are finished, you can proceed to the next stage.
3. Create the WordPress Database on Your New Host Server
To get started with the migration to your new web host, you’ll need to set up a suitable environment for WordPress. This involves creating a database where you can import your existing SQL data.
Begin by logging into your new web host using the provided credentials. Once logged in, locate and access the cPanel software. For this guide, we’ll be using the MySQL Databases application. If your web host doesn’t have this application available, reach out to their support team to inquire about their method for creating new databases.
The steps to create a database are quite simple:
- Open MySQL Database and create a new database with an appropriate name for your website.
- Create a new MySQL user (with a secure password).
- Add this user account to the new database and grant it All Privileges.
Write down the database name, the new MySQL username and its password. You will need them soon.
4. Edit the wp-config.php File
Locate the folder on your local computer where you downloaded your website files. This folder contains a file named wp-config.php, which manages the communication between WordPress and your database.
Create a copy of this file and save it in a separate folder on your local computer. This backup copy will be essential for restoring any changes you make in case of any unforeseen errors.
Open the original wp-config.php file using your preferred text editor and make the following three modifications:
-
Change the Database Name
Locate the following line:
define('DB_NAME', 'db_name');
The db_name portion of this line will currently be set to the MySQL database name of your old 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 find the line:
define('DB_USER', 'db_user');
In this line you need to change the db_user portion from the username of your old host to match the new username you have just created.
Change the Database User Password
Finally, edit the third line:
define('DB_PASSWORD', 'db_pass');
As with the others the db_pass section of this line must be changed to the new secure password you created for your MySQL user.
Save wp-config.php and close the file.
5. Import Your WordPress Database
Now that you have a new database to work with we can begin the import process.
Launch phpMyAdmin from the cPanel software on your new server and select your new database from the list on the left hands 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 previously.
Un-tick the Partial Import check box, make sure the format is set to SQL and then click the Go button. The database import will now begin.
The time this import takes varies depending on the size of your database. You should receive a message informing you of the success of the import when it has finished.
6. Upload The WordPress Files To Your New Host
With the new database in place and the wp-config.php file updated, it’s time to transfer your website’s files to the new hosting environment.
Using an FTP program, connect to your new web host and navigate to the directory where your website will reside. For the primary or sole website on this server, the standard location is the public_html folder.
Once the remote directory is selected, proceed to upload your website files, ensuring the updated wp-config.php file is included. Similar to the earlier download process, this may take some time.
Do not delete these files from your local computer after the upload is complete. They remain necessary until the final steps are concluded.
7. Defining New Domain & Search/Replace Old Domain
If you are moving to a new or different domain, you should review this step. Otherwise, you can skip this step because there is no need to update your site to a different domain.
One issue people always seem to have when moving their site is that they’ve added links to other posts on their site or inserted images directly by pointing to a URL on the server, causing these to break when moved over to a new domain. If you want to quickly and easily search for any instances of your old domain name and replace with the new name we suggest you take a look at the Search Replace DB script on github. This will allow you to do this with great ease. Just make sure you DELETE it when your are done (for security reasons) and don’t place it in your root domain, create a temp folder with a random name to host the script.
Changing Site URL: By doing a search and replace for the old domain and replacing with the new domain you’ll also be altering the site_url and home url values in the database (Changing the Site URL) which will ensure that when you try to log into your site on the new domain it doesn’t try and redirect you over to the old domain.
8. Final Touches
This step includes two mini-steps that may take several days to complete.
First, you need to reconfigure your domain’s DNS settings before using the site on your new host. The DNS settings are currently pointing to your old host, and you need to change them to point to the new server IP address.
The process of changing DNS settings varies depending on where your domain is registered. The details of this process are too complex to discuss in this post, but your domain registrar should have all of the information you need to make the change.
DNS changes can take up to 2 days to fully take effect. It is best to do this when there is less traffic on your website. During this 2-day period, you should not make any changes to your website, as you may change the old version of the website.
Second, after the 2-day period has passed, you should now be able to access the new web host when you go to your website. At this point, you can go to your old web host and delete the files and database. You should still have a local backup of these files and a database export, as well as the original wp-config.php file, in case you need to revert the migration. It’s a good idea to keep these files for a while, just to be safe.