There are various methods available for transferring hosted wordpress blogs from one host to another, with ease. But when it comes to bigger blogs with thousands of files, over hundred even thousands of MBs MySQL database – the process can become never ending and hectic, especially if you are on a slow internet connection.
I am going to tell you a way to shift your wordpress blog with ease, in just 20 minutes (we did it practically when we moved ProPakistani from VPS.net to Wiredtree.com)
First of all make sure that your new VPS or dedicated server, with root access, has following applications installed:
Once you have these applications installed, make sure you have added your domain on this new web server. Adding a domain through cPanel is easy, if cPanel is not available – you might need to add a domain via SSH through this tutorial.
If you don’t know what SSH is then you shouldn’t be reading this tutorial, and ask someone to make this wordpress transfer work for you.
We are assuming that you have added your domain and at this point of time you are done with server configuration and all.
Time to shift your wordpress files and databases now.
Making a Backup of MySQL database with SSH
Before we transfer files, we need to take backup of MySQL database used for wordpress.
We are making backup file now because, we will shift this backup file to new host with all other files.
Login on old host with SSH, and use following command:
mysqldump -u username -p database_name > /home/propakistani/public_html/dumpfile.sql
This command will make a backup file for your MySQL database and will place it in public directory.
Caution: This is a public directory on a webserver, so leaving this database backup file here for long can be risky.
scp -r [email protected]:/home/username/public_html/ /
Command Explanation: In this example, command will transfer all files from your old host (/var/www/html) to local working directory, i.e. /home/propakistani/public_html
parameters used in command are:
After asking for password, this command will start copying all the files from old host to this new host. It can take time, depending on your files’ size.
We had 600 MBs of files with over 100 MBs of database, and it took us 15 minutes to transfer all files to new host.
File Transfer Done, now what?
Now, when all your files are transferred from old host to this current host, its time to import your database backup file. (which is also transferred to new host – remember, we took a back and had placed it in public directory). Now its time to use this file.
Importing MySQL Database using SSH
we are assuming you have access to MySQL, preferably with same username/password as you had on previous host. This way, you don’t have to change anything in your wp-config.php file. If you have new username/password for MySQL, and new database name, change all the settings accordingly in wp-config.php.
Let’s start the import of MySQL database. We are assuming that your working directory is public_html, type following command in SSH
mysql -u username -p database_name < dumpfile.sql
And you are done!
Making sure everything is good:
At this point of time, you are done with transferring of WordPress files and databases to new host.
Let’s do the testing to make sure you have done it right. For this, we will access our wordpress blog from new host by adding IP address in windows Hosts file.
For the purpose, make a slight change in theme on new host, for instance, in the footer.php before </body> add this line “hosted on new Host” and save the file. This will help you identify if the files are served from new host or not.
Open notepad with administrative rights (you can do this with right clicking on notepad icon and selecting “run as administrator”)
your_new_host’s_IP Address yourdomain.com
your_new_host’s_IP Address www.yourdomain.com
in our case, it was like following:
Save this file and close it.
Now go to run, and type: ipconfig /flushdns
Now, open wordpress blog’s address in any browser, and bingo – check the footer, if it has “hosted on new Host” written, then you are being served from new host.