In theory transferring a WordPress website should be a straightforward process that involves few well-defined steps like: export your database from the old host, import it on the new one, move your files, reconfigure WordPress and change the DNS records. Not much can go wrong you may think, but actually on each step things can occur causing trouble and preventing your successful transfer. In this post I will go through the most common of these issues and try to give you tips I learned from migrating hundreds of sites to SiteGround servers.
phpMyAdmin Timing Out when Exporting/Importing a Database
Your database is not just a file that can be moved from one place to another. It has to be exported to a “dump” file, transferred and then imported into an empty database on your new host. There are several issues you can face doing this.
The most common one is the phpMyAdmin tool timing-out. Although it is great software, it’s likely that you won’t be able to export a big database. It’s even worse for the import process because the dump file of your database has to be uploaded first.
The good news is that you can get around these issues using WP-CLI and generic SSH commands. One of the main reasons we’ve preinstalled WP-CLI on all our servers for example is that you can simply type:
EXPORT: wp db export for-transfer.sql
IMPORT: wp db import for-transfer.sql
and you will have a backup of your database in no time. If you don’t have WP-CLI installed, but you have SSH access you can use the native command for that:
EXPORT: mysqldump -uUSER -pPASSWORD DBName > for-transfer.sql
IMPORT: mysql –uUSER –pPASSWORD DBName < for-transfer.sql
If that fails to work, timeouts or the command is not available, your last resort is to request a backup of your database to be created by the support team of your old hosting provider, and/or to ask your new host to import the dump file into a new database for you.
Files Taking Ages to Download and Upload
Although it seems trivial, you can definitely face these issues if you have a very big WordPress installation with a lot of multimedia. Most people start downloading their files and folders locally via FTP, and then upload them to the new host. Usually, that takes ages. Here are few tips on how to speed up the process.
First, make an archive of your site files and transfer it. It’s faster to move one big file rather than thousands of small ones. Much, much faster.
Next, if you have SSH access to your new host, login and download your files’ archive directly from your old hosting provider to the new server. This will save you a step of downloading your archive to your local computer and then uploading it, and it will be at least two times faster.
Some hosting providers offer only SFTP access to your account. I personally think that’s not enough to adequately manage a WordPress site. Mostly because you don’t have access to WP-CLI and you can’t execute tasks like the one described above with the same ease.
Configuration Issues after Migration
Once you have successfully transferred your database and files you need to do some reconfiguration in your wp-config.php file and alter the database settings to match your new database name, user and password. After you complete these reconfigurations you should change your DNS settings and in a few hours your domain will start opening your blog from the new location. Unless…something is not working the way it should, which unfortunately happens a lot, especially if you don’t test enough.
It is a good idea to check if everything is OK with your site on the new location before making the DNS change. Almost all providers have direct URLs that you can use to access your account, even if you do not have a domain name associated with it yet. For example, if you’re hosted with SiteGround, that would be something like: http://siteground123.com/~username/. You can add these lines to the functions.php file of your theme to configure WordPress to work from the new location:
Once you make sure that your site is working well, change those lines to your actual domain name. Then, load your website from your actual domain name, check if it is working fine again, and then simply remove the two lines because your home URL is already stored in the WordPress database.
Internal Server Rrrors Due to Wrong File Permissions
Some hosts allow you to have permissions like 777 for your files. When you transfer files from one host to another, their permissions are moved too. Such file permissions present a huge security risk, and if you are switching to a host that cares about security that should result in an “Internal Server Error” page.
SiteGround has 1 click permission fix for all your WordPress files as part of our WordPress Management Toolset. However, if you don’t have such a tool at your disposal, you can manually fix your file and folder permissions via FTP or SSH. It might not be as fast though.
Losing Comments or Other User Activity During Propagation Time
The final step of migrating your website is the DNS change. This part can be tricky too. Domain records changes need the so-called propagation period to take place. This time is required because all the world’s DNS servers need to update their records about your domain name. However, this time is needed only when you edit your domain information like nameservers, admin name, email, etc.
To avoid/decrease the propagation time required, you can edit the DNS Zone on your old host pointing the A record of your domain to the new one. By doing this, even if a visitor is still referring to your old nameserver, he or she will be pointed to the correct new IP address and access the right content.
In addition, while waiting for the propagation period to pass, you can disable the comments on your old hosting account, or even place the old installation in maintenance mode. You can go further and use a plugin like WP Maintenance Mode to create a page telling your visitors that if they see this message, they are loading your site from the old server and advise them to press Ctrl+F5 or Command + R as many times as needed until they enjoy your site from its new host.
If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.