There are basically many ways to migrate a WordPress blog from one web hosting provider to another (or from one hosting plan to another with the same web hosting provider). The easiest one is of course to backup and restore from cPanel for the whole account, but most likely you’ll have to pay to your web hosting provider to provide such service. Though HostGator (where this blog is hosted at) gives you one free transfer when you register a new hosting plan with them, sometimes you are required to do more migrations in one go.
Here is my way of migrating WordPress using cPanel. I’m assuming that you want to migrate a WordPress on a domain (let’s say mydomain.com for an example), from one host to another (or from say a Reseller plan to a Shared or vice versa).
I’m also assuming that you want to transfer all your current files (not just your WordPress blog) that you may have in your account.
On your Current/Old Account
Backing up files
[-] Go to your current account’s cPanel (i.e mydomain.com/cpanel).
[-] We need to backup all of your files in that account. Go to File Manager and select “Web Root (public_html/www)”. Don’t forget to tick on the “Show Hidden Files”.
[-] Select all files and folders and click on the “Compress”. Choose “Gziped Tar Archive” and name the file to anything you like (let’s say files_backup.tar.gz). So the file will be saved to /public_html/files_backup.tar.gz. Click on the “Compress File” button to start. This will take a long while, depending on how many files you have on your current account.
[-] Once finished, close the pop-up window and then click “Reload” to refresh the files listing under that File Manager. You should now see your files_backup.tar.gz. Download it to your local computer.
Backing up your WordPress Database
[-] Back to cPanel, select phpMyAdmin
[-] Click on your WordPress database on the left (once phpMyAdmin is open). Click on the “Export” Tab.
[-] Export your database (you can just use the “Quick” export method) and save the file to your computer (the file should have a .sql extension).
Before transferring things to the new one, I normally make a small modification to the latest post or something. This way, I know that if the domain name has been propagated to the new host (because it still has the old post without the small update).
On the New Account
Restoring your files
[-] Go to your new account’s cPanel (most likely you’ll only be given an I.P address at this stage since you haven’t redirected your old domain to the new one yet).
[-] Go to File Manager again using the same settings as before.
[-] Upload your files_backup.tar.gz to the public_html/ folder and then “Extract” it. You may have to Reload the listing if you can’t see your uploaded file.
[-] After extracting, again, reload the listing and you should see all your backed up files there.
Restoring your WordPress database
[-] Go to cPanel->MySQL Databases. You need to create a new database and user for your WordPress. Most likely it will be different than the old (since a web hosting provider would add your account username as a prefix to any database and user you create).
[-] Create a new database (ex: myusername_newsite)
[-] Create a new user (ex: myusername_newuser). Don’t forget to write down your password.
[-] Go Back to the same screen and add the user to the database (giving ALL PRIVILEGES)
[-] Go Back to cPanel and go to phpMyAdmin
[-] Click on your database on phpMyAdmin left sidebar and go to the Import tab.
[-] Upload and import your .sql export file earlier.
[-] Now go back to cPanel –> File Manager and go to your WordPress folder. You should be able to find wp-config.php file.
[-] Open it in the Code Editor and change your old settings to the new (i.e update your DB_NAME, DB_USER, and DB_PASSWORD). Pay attention to some settings here too, for example I notice a new “WPCACHEHOME” (from a WordPress caching plug-in) pointing to the old path. Update it to your new one (i.e: /home/[new account username]/]
If you are using WP-SuperCache or any other plugins that make errors, remove the plugin folder using File Manager. Just do a reinstall of the plugins later.
Don’t worry if things don’t really work yet. Most likely it’s because your WordPress Settings are still using your domain name (rather than the I.P address of the new account). You can now redirect your domain from your old to the new (i.e changing the nameservers of your domain name). Once the DNS is propagated (might have to wait for 12-24 hours), you should be good to go!