Sometimes it happens that you have to move your blog to a different hosting or location. Even I Have moved my WordPress site couple of times. First time I moved from a free hosting to a paid one, second time to a better hosting. Anyway I am going to tell you how you can move from one place to another with all your data.
There are two ways to do that. One is the expert way and another is the easy way. Let’s talk about them both.
The Easy Way:
The easy way is to move with your data into the .xml format. Login to your WP admin panel and from the left side panel find the option “export” under “Settings” section.
01. Choose “Export” from there and it will show you how you want to backup all your data. You can choose all at a time with all users post or you can choose individually and by date. Choose carefully as you may see some host won’t allow you to upload an .xml file more than 10 mb while some will allow you to upload around 25mb. So create the xml file according to your need. But take all data backed up.
02. Next, you have to log in with your ftp into the host. If you are not expert please read some manual on how to use the ftp. With the ftp you have to go to the root folder where your WP site is installed. Download the wp-content folder with all its content. It’s better to download the full folder. So, you are done with your entire backup.
03. Now install a WordPress on the new hosting or server. I would prefer cPanel with fantastico or Softaculos, so I can install it with one click. After installation Log in with ftp again but this time into the new hosting/server where you have just installed WordPress. Upload the wp-content from the previous hosting you got, and overwrite the new installations wp-content. We are doing this because we don’t want to lose the theme, plugins and pictures that were attached to the post.
04. Lastly you have to log in the wp-admin panel of the newly installed wordpress and find the import option from the left side panel under the settings tab. Import the .xml file/files you have created earlier. You might be asked for the wp-importer pluggin, normally it does. Install the plugin and everything will be easy. Don’t panic you have the backup so nothing can go wrong. After you have completed the import you will have all the content and images back. Now play with the WP-admin panel to reactivate your themes and plugins. It always works.
Remember one thing, when you are switching the name servers your site might be unavailable for hour’s even days. It takes time to propagate the new name servers along the web. Normally it happens within 5 hours if your domain registrar is fast. If you don’t want to have your site offline for hours when moving the site, then you have to follow the expert’s way.
The Expert Way:
First of all- You must have some knowledge about MySQL and phpMyAdmin in the Cpanel of your hosting. I mean how to normally handle those, because we are going to create backup from there.
01. First, log in with the ftp into your hosting and download all the WordPress files from your sites root directory. If your site is the main domain of your hosting then you might find those in the “public_html” directory. If the site is an add-on domain in the cPanel, then you might find them in that domains folder inside the “public_html” folder. Guys I am talking about the cPanel hosting environment.
02. Next, log into your cPanel and find the databases section. You will find the phpMyAdmin there. Click on that, it will open in a new window. You can see the databases in the left column of phpMyAdmin. Select the database of the site you are going to move. Now click on the export tab on the right panel. You will there get option which database tables you are going to backup. Normally all are selected with blue, let it be that way. You will see the output format is “SQL” selected as the default format, leave it if you are not an expert. As we want to export it in that format. Click on the Go button at the bottom. You will be prompted to save the SQL file. Save it and all of your backups are done.
03. Now log in to your new hosting area with ftp and upload all your files you have downloaded (in the first step). Upload them where you want to put your site. Suppose your new hosting’s main domain is the site you are moving, then upload them in the public_html folder. It is not always that “public_html” will be your root folder. If that is an add-on domain you will see a folder of that domain inside the “public_html” folder. Upload them in that folder.
04. Create a database from your cPanel. You have to create a user also and attach it with the newly created SQL database. You can easily do that from the Database section=>MYSQL Databases in the cPanel.
05. Now go to phpMyAdmin and select the database you have just created. Now import the SQL file you have created in the second step. That will be your entire backup done.
06. The last thing is changing your wp_config.php file. I hope you know where to find it. You have just uploaded it in the root directory of the domain. Put/change the configuration cardinals with your new database name, user and password. If you are not sure about the host, leave it as “localhost” or ask your hosting provider for details.
So, you should now up and running. Just change your name server to the new hosting in the domain control Panel. Your site won’t /shouldn’t be offline for hours.
Are you trying to change the folder or domain?
It is like your site was in: http://www.somename.com/folder/ and now you want to have it as http://www.somename.com .Or you want to change to a whole new domain. If this is the second case then moving the site in the “Easy Way” will be better. But in both case you have to run some SQL queries that will change the names in the database accordingly.
This will update the WordPress settings:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old_domain.com', 'http://www.new_domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
This will update the permalinks:
UPDATE wp_posts SET guid = replace(guid, 'http://www.old_domain.com','http://www.new_domain.com');
And this query will update the links imbedded in the content:
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old_domain.com', 'http://www.new_domain.com');
Don’t forget to run the query without the www extension also. So you have to run the query two times. Forget to say, you will run this command from the phpMyAdmin. All the best guys.