Moving WordPress from hosting to Localhost

Moving WordPress from hosting to Localhost
Moving WordPress from hosting to localhost can be done in several ways. But in this time I will try to explain two of them.

The first way (the easiest one) is by using WordPress Export/Import Tools.

But before we begin to move the WordPress from hosting to localhost make sure that you have already installed a fresh copy of WordPress on Localhost. You can follow the instruction here on How to Install WordPress on Localhost.

Login to your live WordPress Blog, enter the Admin page. In the navigation menu, mouse over the “Tools” menu and then click “Export”

Download WordPress XML File

Check “All content” to download all your posts, pages, comments, custom fields, categories and tags in a single WXR (xml) format.

Click on “Download Export File” and save it in your computer.

In Localhost, login to your WordPress, enter the Admin page from the Tools menu click “Import” and then klick “WordPress”

WordPress Importer

By default Wp importer plugin is not installed with WordPress, so if you see a pop up window about the plugin, just klick “Install Now” to install it.

After the plugin has been installed you’ll be taken back to the WordPress import window, browse to the WXR (xml) file you’ve downloaded and then klick “Upload file and import”

Import WordPress XML File

Make sure you are connected to the internet to be able to download file attachments. Create a new user or select a user for “assign posts to an existing user”, check the “Download and import file attachments” checkbox and then click “Submit”

Worpress Attachments

Open your FTP program and download plugins/themes from your hosting. Switch the theme and activate the plugins, arrange the widgets to make it look exactly like your live WordPress.


The second way is using phpMyAdmin to Export/Import database.

This method is more complex but more efficient because all the settings, themes, plugins, widgets and even username and password will be the same as live WordPress.

I want to tell you that this method also can be used to move Wordress from one hosting to another hosting as I did or to move WordPress to a new domain as well.

Here is a step-by-step guide to move WordPress from hosting to Localhost

Open your favourite FTP program and connect to your hosting, navigate to the path where the WordPress is installed.

Download “wp-content” folder and its contents, or you can use cPanel File Manager to compress the “wp-content” folder, so the file will be much smaller to download.

Replace “wp-content” in localhost (D:\My Websites\wp-content) with the new downloaded “wp-content” folder.

Login to Cpanel and then click phpMyAdmin.

cPanel phpMyAdmin

In the database list, click your WordPress database (if you are unsure, open wp-config.php to find out what your WordPress database name is). In this example mine is “htmlcss”

Select WordPress Database

Click “Export” to export the database

Export WordPress Database

In the Export Method select “Custom – display all possible options”

Export WordPress DB Option

Select “zipped” or “gzipped” for compression type.

Export WordPress DB Compression

Click “Go” to start downloading the database.

Open phpMyAdmin on localhost, if you followed the instruction here on how to install phpMyAdmin on Windows, you could open it by typing “http://localhost/phpmyadmin” in the browser address bar.

If you want to use WordPress database that you have already installed, select it and at the bottom of the table list click “Check All” then select “Drop” in the drop-down list and click “Yes” to delete all the tables.

Drop WordPress DB Tables

Or if you want to use a new database, here is a guide of how to create a new database and then edit wp-config.php to match the database name.

Select the database that you want to use and then click “Import” browse to the zip or gzip that we have downloaded earlier.

Import WordPress Database

Click “Go” to start importing the tables to the database. If everything went well you should see something like the image below.

Success WordPress DB Import

In the WordPress table list click “wp-option”

WordPress Options

In the table rows list find “siteurl” option_name and then click “Edit”

Worpress Siteurl

Change the option_value with “http://localhost” click “Go” to update wp_option.

WordPress Siteurl Value

Still in the table rows list find “home” option_name and then click “Edit”

WordPress Home

Change the option_value with “http://localhost” click “Go” to update wp_option.

WordPress Home Value

Now try browsing to “http:/localhost” to view your blog then login using your username and password live WordPress.

To be safe and to make it load faster, you should remove any scripts from your theme and widgets that require internet connection such as Analytic, Webstats, Shoutbox, Adsense Script etc…

If you face the problem with “the requested URL was not found on this server” try to resave the permalink settings in the WordPress settings page.

Posted by Admin on Friday, July 27, 2012 Email ThisBlogThis!Share to TwitterShare to Facebook
Labels: Localhost
Thomkins GilesAugust 31, 2012
This is what I am looking for. I am still a wordpress newbie and I love what I learned from here. Thanks!

Repliessimin(:February 05, 2013
This comment has been removed by the author.

simin(:February 05, 2013
I second the above comment. You have no idea how much this helped in my work. Thank you so much! (:

Korky KathmanDecember 09, 2012
This seems to be an awfully simplified approach, especially since it doesn’t address the serialized database aspect. Almost all other approaches require that you use some search and replace tool such as the one from interconnectit to do the global search and replace.

LiezlFebruary 13, 2013
Thanks for the tutorial… but is there a way to automatically update the live site from a localhost? I mean like in dreamweaver where you have the options to connect to the ftp?? So you don’t have to import/export everytime you have changes to be made…

pls like and follow my blog @

RepliesAdminFebruary 13, 2013
No, you still need to import/export your database (posts, comments, and settings) to be able to update your WordPress site.

When we setup Dreamweaver FTP correctly, it can be used to upload/download, update and synchronise Wordpess files/folders between local and remote server.

Nice blog by the way 🙂

AnonymousFebruary 17, 2013
OMG…I’ve been searching ALL day for this.

The biggest thing I learned was the re-save permalink settings. That was awesome!

daveFebruary 21, 2013
I have done everything that you have said in this post (as well as looking at other tutorials) and I am getting the error:
Error 404 – Page not found!
The page you trying to reach does not exist, or has been moved. Please use the menus or the search box to find what you are looking for.

Is there something I am mising?
Please help! I have looked everywhere! I am trying to get my site from a live domain to a local host.

RepliesAdminFebruary 21, 2013
Is that a WP error 404 page? if so, maybe mod_rewrite is not enabled in your httpd.conf, you can read it here for more detail. After that, (if exists) delete .htaccess from your Document Root and go to your WP Permalink Settings, try to change your Permalink structure and then save.

daveFebruary 22, 2013
Thank you for replying!
Yes I am using wordpress – so I am basically trying to move a wordpress site from a live domain to a localhost.
It seems like it is much more tricky than the other way round!

The landing page gives me a wordpress 404 error.
When I try going to wp-admin I get:
Not Found

The requested URL /wp-login.php was not found on this server.

I understand if this is not to forum to get assistance but I just can’t figure out why I cannot get it to work after trying numerous tutorials!

AdminFebruary 23, 2013
I think it’s good just to start over, maybe you’ve entered wrong url into the wp-option.

Delete all the tables and reinstal WP and try posting some posts and play with the permalink structures and see if it makes the same problem.

Go to WP setting and write down the WordPress Address (URL) and Site Address (URL)

After you’ve imported the live WP database, enter the WordPress Address (URL) into “siteurl” and Site Address (URL) into “home”

If the the problem still persists, check if you use any WP rewrite plugin, or simply rename wp plugin folder to something else.

daveFebruary 27, 2013
Sorry for the delayed response (a bit like my brain at the moment).
I have finally worked it out!
It was my foolishness as I hadn’t put the live site directly into the root so it needed an extra location (/).
My issue now is that when I try to log on to the Wp-admin it doesn’t accept my password. I have checked that it is correct with the live site.
Is there a way to reset passwords? Or is there something else I am doing wrong?

AdminFebruary 27, 2013
You should be able to login using live WP Password. I guess, there must be something wrong but you can try to reset password and see if that works.

There are many ways to reset Wp Password, resetting through phpMyAdmin is the easiest one.

Chukwudi Emmanuel UdegbunamMarch 19, 2013
Thanks for the tutorial sir. I used the second option and all is running well BUT I’m having issues with images.

How do I change the URL of the post images to link to the copies on localhost and not those online?

Thanks sir.

RepliesAdminMarch 20, 2013
Here are other options if the above option does not work for you. it can happen when we manually insert images to the posts or using absolute links for internal linking.

So, the best way is do global find and replace.
Unzip the database you’ve downloaded and open it with text editor (Notepad++ or Dreamweaver) and use “Find and Replace” option to change “http://yourdomain.tld” with “http://localhost” and then import it with phpmyadmin.

Or you can also using phpMyadmin’s SQL queries. Change the “http://yourdomain.tld” below with your url, copy and paste them into phpMyadmin’s SQL queries and hit “Go”.

UPDATE wp_options SET option_value = replace(option_value, ‘http://yourdomain.tld’, ‘http://localhost’);
UPDATE wp_posts SET post_content = replace(post_content, ‘http://yourdomain.tld’, ‘http://localhost’);
UPDATE wp_posts SET guid = replace(guid, ‘http://yourdomain.tld’,’http://localhost’);
UPDATE wp_links SET link_url = replace(link_url, ‘http://yourdomain.tld’, ‘http://localhost’);
UPDATE wp_links SET link_image = replace(link_image, ‘http://yourdomain.tld’, ‘http://localhost’);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://yourdomain.tld’, ‘http://localhost’);
UPDATE wp_usermeta SET meta_value = replace(meta_value, ‘http://yourdomain.tld’, ‘http://localhost’);

Chukwudi Emmanuel UdegbunamMarch 20, 2013
Thanks a lot sir. The SQL queries helped fix the problem 😉

AdminMarch 21, 2013
You’re welcome, I’m glad the SQL queries fixed your problem. 🙂

Big AlApril 23, 2013
Thanks so much for this tutorial! It helped me a lot!

Ruslan BershtinMay 11, 2013
Great blog article about this topic, I have been lately in your blog once or twice now. I just wanted to say hi and show my thanks for the information provided. T&T Web Services