Protect your sites from hackers and boost performance with Sucuri’s Junior Dev Security Bundle — now $500 off.
How to Create a Local Copy of a Live WordPress Site

How to Create a Local Copy of a Live WordPress Site

Update: This is an old article (from 2012), and as such it may contain information that is now obsolete.

How to Create a Local Copy of a Live WordPress Site

In Monday’s tutorial on creating a local WordPress site, I said that all WordPress users should have a local installation of WordPress on their PC. One of the key reasons for doing so would be the ability to test design changes without disrupting the live site. I’ve certainly been guilty of fiddling with my live blog and regretting the outcome. If you have also been guilty of carrying out design tweaks on the fly, now is your opportunity to take your experiments offline.

As you now know, creating a local WordPress site isn’t difficult at all – in fact, it only takes a few minutes. But on the face of it, copying an actual live site and moving it offline seems like a far more daunting task. Fortunately, it isn’t. Just follow the simple steps below and you will have an offline version of your WordPress site up and running in no time at all.

1. Activate Apache and MySQL

This first step assumes that you have gone through the process of creating a local WordPress site. If you haven’t, just head over to that tutorial and complete steps one and two. You will be installing Xampp for Windows, and activating Apache and MySQL on your PC. In layman’s terms, you will be setting up a local server that your WordPress installation can sit on.

If you are a Mac user, don’t fear – just complete steps one and two in this tutorial instead.

2. Copy Your Site’s WordPress Files

Now you need to grab your live site’s WordPress files and copy them over to your local server.

Access your live site via FTP. Once there, you want to download all files relating to your site. They will be contained in a root directory such as “yoursitename”.

If you are in any doubt as to what you are doing, look out for a directory containing folders such as “wp-admin” and “wp-content”. There will also be a bunch of files in that directory, such as “index.php” and “wp-config.php”.

Once downloaded, place that root directory into the “htdocs” folder, which can be found in the location where you installed Xampp (by default, you can find it at “C:/xampp/”). If you’re using a Mac and MAMP, follow the same instructions but adjust the local directory to suit.

To check that the files have been successfully transferred, open a browser tab and navigate to “http://localhost/yourfoldername/”. You should see a database error similar to this:

Local WordPress Site

3. Export Your Site’s Database

At the heart of every WordPress installation is its database, and it is not contained within the files you downloaded. So now we need to grab it and install it locally. But before we do so, we need to know which database we are actually looking for. Fortunately, that information is contained within the files you downloaded.

Just navigate to the root directory of the fresh copy of your site located on your PC, and open up “wp-config.php” in a plain text editor. You’re looking for this line:

Local WordPress Site

That is the name of your database – make a note of it.

Now you need to login to phpMyAdmin, which every good hosting provider offers. Here’s where you will find it on cPanel (which the biggest hosting providers all use):

Local WordPress Site

If you’re struggling to find it, contact your hosting provider – they should be able to help.

Once logged into phpMyAdmin, click on the “Export” tab. On the following screen, select the “Custom” export method. You will then be presented with a selection of databases to export:

Local WordPress Site

You only want to export the database that you made a note of above, so click on that one. Ignore the rest of the custom settings, and click on “Go” at the bottom of the page. The database will be downloaded to your PC.

4. Import Your Site’s Database to Your Local Server

Now we want to take that same database, and import it via your local server’s phpMyAdmin. To login, open a browser tab and type in “http://localhost/”. If you are using Xampp, a main menu will pop up, and you will see an option for phpMyAdmin in the sidebar:

phpMyAdmin

If you are using MAMP for Mac or a similar program, you should be presented with a similar screen.

Once logged into phpMyAdmin, select the “Import” tab. From this screen, select the database file that you exported from the live server, and click “Go”.

5. Set Up the Database for Local Usage

The database will now be imported into your local server’s phpMyAdmin. Once that process has completed, click on the “Databases” tab. Your site’s database should now appear in the list. Click on the “Check Privileges” link next to your database:

Privileges

In the next screen, select the “Add user” option. You will be presented with a screen similar to this:

Add User

You can find the user name and password in the same “wp-config.php” file you accessed earlier on. You’re looking for the “DB_USER” and “DB_PASSWORD” variables. The host is simply “localhost”. You do not need to edit any of the other settings – just click “Add user”.

Finally, you need to edit two fields within the WordPress database itself. Navigate back to the “Databases” tab and click on your database name. When you open the “wp_options” table, you’ll see a list of table names like this:

WordPress Database Tables

The two fields you need to edit are “siteurl” (highlighted above) and “home” (which you may need to navigate to the second page to find). Just click the “Edit” buttons next to each field, and replace the URL contained in “option_value” with “http://localhost/yourfoldername/”.

That’s it! If you now navigate to “http://localhost/yourfoldername/”, your site should load up in all its glory. Please note that if you use custom permalinks, you will need to change them to default (in the WordPress > Settings > Permalinks screen) in order for internal links on your site to work. You can of course change the permalinks back to their custom form at any time.

Enjoy!

Creative Commons image courtesy of e³°°°

Tom Ewer Avatar

159 responses

  1. littleguy Avatar
    littleguy

    Except all the links to pages and images are defaulted to absolute URIs when you add them, so none of your links or images will work. This is a huge problem with WordPress, not the tutorial.

  2. Colin Crawford Avatar
    Colin Crawford

    I went the other way Local to Live and as littleguy said your images and other links have to be changed as well or otherwise they don’t work or you can’t view the images. Good job I didn’t have that many and made the changes within the pages and posts.

    The images were pointing to local host. There is a utility here Search and replace for WordPress databases/, I’ve not used it yet but it might be useful.

  3. Glenn Tate Avatar
    Glenn Tate

    One problem is with the serialized data. Options especially Theme options are stored this way and will break when the url is changed without changing the string length. Luckily there is this tool.

    http://interconnectit.com/124/search-and-replace-for-wordpress-databases/

  4. Dynasites Avatar
    Dynasites

    I went through the first tutorial with no problems. I then installed Socrates Theme v3.04 and began getting errors. Couldn’t even login to admin.

    Through Explorer, I just deleted the Socrates theme folder and everything worked fine. Forum support said…
    “Usually it has a different error message than that but one problem people have seen with Wamp installations is the cURL php library not being installed/activated.”

    This is way beyond my expertise, but I will refer to that post here in case some one has run into this challenge before and has an easy answer.

    Other wise, I really appreciate these articles, and the ManageWP Blog. As a ManageWP customer, your resources have helped and educated me faster than anything else!

  5. Felicia Avatar
    Felicia

    I keep getting “Server Error The website encountered an error while retrieving http://localhost:8888/essencia/. It may be down for maintenance or configured incorrectly.”

    I’ve also tried http://localhost:8888/foldername still giving me the same “Server Error” prompt.

    Everything has worked fine for me up until this point.

  6. Michael Vila Avatar
    Michael Vila

    Excellent instructions, easy to follow and the images are great! Worked perfectly. FYI, siteurl and home are both under the wp_options table. And please, if you change the permalinks, DO NOT FORGET to change them back or you will break previous Google indexeing.

    Thanks again!

    Mike

  7. alanbu Avatar
    alanbu

    Really useful, thanks – As a complete beginner, I found this really easy to follow. I have only one problem, and I hope someone can help. When I try to import the database into myphpadmin on my pc, I get the error message shown below. I have tried to download the db fromthe website a number of different ways – the resultant file always seems very small (ABout 3Mb) if it is supposed to contain pictures &c from the site. Any idea what i am doing wrong?

    Error

    SQL query:

    — phpMyAdmin SQL Dump
    — version 2.6.4-pl3
    http://www.phpmyadmin.net

    — Host: db410283526.db.1and1.com
    — Generation Time: Mar 29, 2013 at 11:51 AM
    — Server version: 5.1.67
    — PHP Version: 5.3.3-7+squeeze15

    — Database: `db410283526`

    — ——————————————————–

    — Table structure for table `wp_commentmeta`

    DROPTABLEIFEXISTS`wp_commentmeta` ;

    MySQL said:
    #1046 – No database selected

  8. alanbu Avatar
    alanbu

    Thanks Michael Vila!

    Getting there (I think!). Can create a new web site and phpMyAdmin says I have successfully ipmorted my live database into a newly created database.

    I have created the user & password using the data from the config file.

    The database name in config is used as the database name in phpMyAdmin, and as the folder name in htdocs.

    The home & siteurl are set to http : //localhost/db410283526/ again reflecting the database name

    However, I am now stuck at the last hurdle – whatever I try, I get:

    The website cannot display the page

    HTTP 500

    Most likely causes:
    •The website is under maintenance.
    •The website has a programming error

    Help!!!

  9. Rama Avatar
    Rama

    You may find it better to use LAMP instead. Most WP sites are on LAMP servers (and there are differences).

    For those who are still Windows users, a more stable approach would be to have a separate box with LAMP on it, which also keeps your Windows box safe in the event that something happens. 😉

  10. sara Avatar
    sara

    i did all what you said and it is working but now i can open my live website when i try to open wp-adim it give me a blank page and i found that the host became local host how i can get it back

  11. Brooke Avatar
    Brooke

    Hi Tom,

    Great tutorial for someone like me who has no clue what they are doing 🙂 I have a question – I’m in step two and I transferred the root file in filezilla as described. However when I do the test you mention of going to http : //localhost/foldername/ I do not get an error…there is still an index there of files. I checked my Xammp/htdocs folder and all the files are there. Should I proceed to step 3 or did I do something wrong?

    Thank you!

  12. Cassandra Howell Avatar
    Cassandra Howell

    Thanks for this tutorial. I was following it with great enthusiasm until I arrived at the step where I entered: http://localhost/ and just got an ‘unable to connect’ repeatedly.

    Now I’m pulling my hair out! Any suggestions?

    The other step that stumped me was the very last one, as I can’t find ‘siteurl’ or ‘home’ even in the wp-options table!
    Any help would be greatly appreciated for this newbie!

    Thanks
    Cass

  13. Saad Tariq Avatar
    Saad Tariq

    When I import my site’s database to my local server and click go. I get the following error message:

    Error

    SQL query:


    — Database: `dstazcom_wp111`

    — ——————————————————–

    — Table structure for table `wp_bccf_dex_bccf_submissions`

    CREATE TABLE IF NOT EXISTS `wp_bccf_dex_bccf_submissions` (
    `id` mediumint( 9 ) NOT NULL AUTO_INCREMENT ,
    `calendar` int( 11 ) NOT NULL ,
    `time` datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
    `booked_time_s` varchar( 250 ) NOT NULL DEFAULT ”,
    `booked_time_e` varchar( 250 ) NOT NULL DEFAULT ”,
    `booked_time_unformatted_s` varchar( 250 ) NOT NULL DEFAULT ”,
    `booked_time_unformatted_e` varchar( 250 ) NOT NULL DEFAULT ”,
    `name` varchar( 250 ) NOT NULL DEFAULT ”,
    `email` varchar( 250 ) NOT NULL DEFAULT ”,
    `phone` varchar( 250 ) NOT NULL DEFAULT ”,
    `notifyto` varchar( 250 ) NOT NULL DEFAULT ”,
    `question` text,
    `buffered_date` text,
    UNIQUE KEY `id` ( `id` )
    ) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;

    MySQL said: Documentation
    #1046 – No database selected

    What might be the cause of this. Can anyone hep me

  14. Al Lemieux Avatar
    Al Lemieux

    When I try to import the DB in phpMyAdmin, I get an error on the DB. It points to this line: `meta_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT , and says error #1046 – no database selected.

    What now?

  15. Sep Avatar
    Sep

    Dear Tom Ewer,

    I downloaded a WP site with Httrack software. When I get to install database, I did not find wp-config.php file. So how can I get its database?

  16. komiska Avatar
    komiska

    Hi! Thanks so much for this tutorial – very insightful!

    I hope you do still answer the questions ! –
    I get the “Unable to connect” error when trying to open any of the localhost URLs, whether it’s “localhost:8888/htdocs”, or only “localhost:8888/” .
    I have installed/ imported the WordPress install of a live site together with the DB and put everything into the htdocs folder directly , no “wordpress” folder inbetween.

    Followed everything you’ve written here:created a new DB , imported the one from the live site… all went smooth.
    I use MAMP.
    Changed the “wp-config.php” file , I have tried using “Sequel Pro” to connect to the database, and it does.
    I have changed the “siteurl” and “home” to “http://localhost:8888/htdocs” .
    MAMP is connected to Apache and MySQL.
    Everthing is in place, and i still get the damn error. Where did I fail?

    Thank you very much for the help!

  17. nidhi Avatar
    nidhi

    the tutorial was too gud, i can run website on local in a single shot.thanks!

  18. John Avatar
    John

    Brilliant! Many thanks, Tom, for such a clear and easy-to-follow tutorial. Gave me all the info I needed.

  19. AnaViz Avatar
    AnaViz

    Great post!

    But I had to change the urls inside wp-options to:
    http://localhost:8888/my-site-name/

    it would not work without the 8888

    Thanks!!

    Ana.

  20. Esme Dobson Avatar
    Esme Dobson

    Just wanted to say thank you for the tutorial. Many hours and much frustration, but I’ve finally managed to make a local copy of a site, largely thanks to your tutorial.

  21. Kim Avatar
    Kim

    Hi Tom –

    I followed everything you said here, but my live site won’t duplicate onto the local server. I’m still being met with the initial WP theme/sample post no matter how many times I refresh. I’ve gone over this a bunch of times, gone back and done the steps again.. but it still won’t show up. Any thoughts?

    Thanks!

  22. Peter Avatar
    Peter

    Thank you so much! You saved me!!!!

  23. Stephen Liu Avatar
    Stephen Liu

    Hi,

    I’m running LAMP on Debian 7.2.0 with WordProcess installed on /var/www/ phpmyadmin is also running on the local server.

    On browser /localhost
    IT WORKS

    I ran FileZilla copying the complete website /domain to /var/www/domain but could not make it to work. On browser /localhost/domain popup;
    File not found

    If changing localhost on /etc/hosts to domain then /localhost/domain popup;
    Error establishing a database connection

    I couldn’t resolve. Can you help? Thanks

    Furthermore I ran MySQL commands creating a new database in respect of user, password etc. according the info on /domain/wp-config.php but still I couldn’t make the download website work.

    /domain
    File not found

    /localhost/domain
    File not found

    Please help. Thanks in advance

    Rgds
    Stephen L

  24. Mike Lin Avatar
    Mike Lin

    (sorry for my poor english) My live wordpress site is installed in its own directory named “blog”, I set the homepage as a static page and the blogs on another page named “articles”, each given a navigation tab. After following your above guidance, the clone on my localhost run smooth except :
    1)All images still point to live website URL.
    2)When I clicked my “articles” navigation tab, it opens live web.
    3)On my live wordpress install, index.php file from “blog” directory was copied to root. Do I have to copy index.php to the WAMP’s root? (but inside WAMP root, there is already an index.php file. It seems a part of WAMP).
    4)My permalink is : category-postname-post_id, during setting up above process as per your guidance, when is the right timing to change the permalink to default and set it back to my preferred custom permalink?

  25. Allan Collins Avatar
    Allan Collins

    Hi. I have downloaded my website (not a blog) to my local machine. It all works fine except for Flipping Book (not swearing!) Plugin. Can anybody give me a clue on how to get it to work. I wouldn’t mind having to create my Albums again if I could download Flipping Book to my Local machine. Tx allan

  26. Zoe Hanis Avatar
    Zoe Hanis

    This tutorial was extremely helpful and well written. I just have 2 suggestions for additions since I had such a difficult time.
    1. Explain that the siteurl and home files are inside wp_options.
    2. Unless I missed it, nowhere in here do you have us reconfigure the wp-config file. I am not sure if it is mandatory, but I could not get anything other than a database connection error until I substituted in “root” and “localhost”.
    Thanks.

  27. Dave Avatar
    Dave

    Hi there
    I followed the tutorial, and had the site running on my local PC perfectly. I tried to open the site a few days later and all i could get was a 404 error in IIS7. I found the solution for that and have Apache running on anther port and i can now open phpMyAdmin etc. However I can’t see my website on my PC or log into Wp admin. I just have a blank page.

    Any suggestions would be appreciated 🙂

    Many thanks

  28. steve@tacticks.co.uk Avatar
    steve@tacticks.co.uk

    HI

    Thanks for this, it’s brilliant – I’ve been trying to do this for weeks and now “almost” managed it. Everything fine up to the absolute last step which I’ve replayed below for completeness

    ‘Finally, you need to edit two fields within the WordPress database itself. Navigate back to the “Databases” tab and click on your database name. You’ll see a list of table names like this:
    WordPress Database Tables

    The two fields you need to edit are “siteurl” (highlighted above) and “home” (which you may need to navigate to the second page to find). Just click the “Edit” buttons next to each field, and replace the URL contained in “option_value” with “http://localhost/yourfoldername/”.’

    I don’t see either of these fields when I click back on the database tab and go to the database the only things that show are wp_ files such as links, options, postmeta etc.

    I’m soooooo close to achieving this but do you know what i’ve done wrong? I’d be so grateful for any pointers

    Thanks

  29. Annukka Avatar
    Annukka

    Hi,
    Your tutorial was very helpful, I started with another one, but had problems with getting all the links to work. Your advice on changing the siteurl and home settings in the database was the thing that got everything working for me. Thank you!

  30. Ken Avatar
    Ken

    Hi, thanks for the thorough tutorial. One of the only things missing is, what about the the WordPress admin site login credentials (not the database — those instructions worked fine). I tried logging in with my WordPress user login and password, it doesn’t work. Does it have to be the ‘super user’ Admin login and password? And/or, is there a file in the site or database where these credentials need to be changed? I searched all the site files and database to see if these are stored anywhere — I couldn’t find them anywhere.

  31. Ken Avatar
    Ken

    Meant to further explain– it’s our live site’s user login and password for the admin site, created by our hosting service. I’m not surprised that this wouldn’t necessarily work when moved to my local machine. How can this be fixed?

  32. Lauren Avatar
    Lauren

    Hi there!

    This is a great tutorial, simpler than any others I’ve seen. Alas, I still haven’t been able to get it to work just yet. First off, the site I’m trying to copy isn’t one that I made (it’s a lit mag and its designer is long since graduated from this program), so a lot of its ins and outs are a mystery to me. For instance, in the FTP (which I accessed through Cyberduck), there isn’t a folder (and hence a folder name) with all of the site files. It’s the only site hosted there, so the files seem to just…be there. I just downloaded them all directly into the htdocs folder. So I’m confused as to what I should put as the url in the “site url” and “home” options. I tried a few different ones and neither worked. I created a folder within htdocs, and it also didn’t work, or I didn’t have the right url to direct the server to that folder. I also have to keep MySql running on port 8889 because..well, I think it’s cause I was using an O’Reilly book to learn php, and they also wanted you to set up a local server using Zend, and I think Zend must be using the other port, and I don’t know how to get it to stop.

    Any help?

    Thanks!

    Lauren

  33. IDcreate Avatar
    IDcreate

    This is a great app I used for some of my WP websites. Still testing the application.

  34. Nishant Ratnakar Avatar
    Nishant Ratnakar

    Hi Tom,

    Thanks for the instructions. I have near got all the steps in. But, I am stuck at importing the database. When I try to import the sql file. It fails and gives me a warning as shown below:
    Warning: POST Content-Length of 10306104 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

    Any idea how to correc this?

    Regards,
    Nishant

  35. Bello Avatar
    Bello

    I create a wordpress site using localhost but I want to copy it to another difference computer for hosting and other change. How can I copy the file/folder without losing anything, please help me.

  36. Victoria Avatar
    Victoria

    Changing the values in “siteurl” and “home” options to localhost/yourfilename broke the site – rather, I just changed them to http://localhost and it worked great.

    Also, I don’t have access to phpMyAdmin on my site, but I found a work around by using this plugin to download the database:
    https://wordpress.org/plugins/wp-migrate-db/

  37. Derrick Avatar
    Derrick

    Hi Tom,

    Appreciate the tutorial! I completed your entire tutorial on my MAC and my end result was a completely blank white page. I noticed that I encountered the same blank white page instead of the “Error establishing a database connection” when I initially downloaded and dragged my site’s WordPress folder into htdocs. This makes me thing I’m not downloading my folder correctly or something or other.

    Any ideas or pointers? Thanks a lot.

  38. CK MacLeod Avatar
    CK MacLeod

    Good tutorial, worth being updated. I’d also encourage addition of general comments about the difficulties you may encounter moving relatively large sites, especially ones with singularly large tables. You’ll find a number of posts scattered around the web on that topic, and a number of different tips… and, if you’re like me, you’ll find that none of them work all that well!

    Even as I write this comment, I’m in the process of optimizing and re-optimizing my db, trying to cut it down to size, hoping that this time, when I import the particular problem tables, they will import completely. Then, I’ll see about figuring why other site features didn’t import completely.

  39. CK MacLeod Avatar
    CK MacLeod

    Just wanted to re-emphasize necessity of re-saving permalinks, at least if you want internal links (ilke menu links) to work well.

  40. Gareth Brown Avatar
    Gareth Brown

    Great tutorial, clear and easy to understand. I ran into a problem at the end when it wouldn’t work and discovered that I had to change the My SQL host name in the “wp-config.php” file to “localhost” like this: (‘DB_HOST’, ‘localhost’);
    If anyone is running into problems then try this.

  41. Sandeep Avatar
    Sandeep

    Great support Tom. Your articles really helped me get going in my new WordPress website venture. Very user-friendly articles.

  42. Alejandro Gutierrez Avatar
    Alejandro Gutierrez

    Dude!

    Your post is a lifesaver. There are a million posts out there but yours was by far the most comprehensive while also being straightforward and simple. I want to thank you for taking the time to carefully explain this process. You’re a total badass in my book.

    Cheers,
    Alejandro

  43. Rimbrogno Avatar
    Rimbrogno

    Thanks for the great instructions Tom!
    Although I have tried numerous times from scratch and each time I end up with the same problem!
    Home page (‘localhost/site’) is working ok, but then as soon as I click on a link it takes me to the local/xampp site.
    No idea what I’m doing wrong ??! Any help would be greatly appreciated! Thanks in advance 🙂

  44. Aaron Avatar
    Aaron

    Hi,

    I followed the instructions and can see my site on localhost, however, some things like posts and other pages did not transfer. Also, my user name and password do not work…

    Any suggestions?

    Thanks,

  45. Emerfan Avatar
    Emerfan

    This is a really great tutorial, thank you and much kudos!

  46. matze Avatar
    matze

    hello thx for the writeup. great stuff. guess that i have to correct and configure the “!The two fields you need to edit are “siteurl” (highlighted above) and “home” (which you may need to navigate to the second page to find). Just click the “Edit” buttons next to each field, and replace the URL contained in “option_value” with “http://localhost/yourfoldername/”.

    othwerwise i get blanc pages

  47. Henry Halwell Avatar
    Henry Halwell

    You could probably export it all via widget or something, and whip up a shell script to pull them all down but … It’s a lot of work and defeats the purpose of a dynamic website.

  48. Brad Avatar
    Brad

    By now, isn’t there a software application that can do all of this for me, instead of having to re-configure all of the settings back-and-forth?

  49. Dan Avatar
    Dan

    Great article, just did it and it worked a treat. However I couldn’t find reference to the ‘siteurl’ or ‘home’ in the last part and yet my site is still working locally! Either way you’ve made me a happy boy. Thanks.

  50. JV Avatar
    JV

    Great tutorial, just the few hiccups mentioned earlier by others. I found the site_url and home fields in the wp_options table, I had to set wp_config .php to use ‘root’ on ‘localhost’ and I had to reset .htaccess by visiting settings, permalinks and clicking on save. Now all is working!

  51. bsarioz@gmail.com Avatar
    bsarioz@gmail.com

    I followed the tutorial, but I get a blank page after trying localhost:8888 which is the port where my website locally runs.

  52. Ade Avatar
    Ade

    I followed this tutorial to the letter, including the changes required to ‘home’ & ‘siteurl’ in ‘wp_options’ but I am having an issue that I hope someone can help with!

    Firstly, I had to manually import my .sql file (DB) as it was too big for phpMyAdmin to cope with, which was not a problem. When I navigated to localhost/mywebsite the home page loaded but all the hyperlinks on the page pointed to the live site! So I changed all the hyperlinks in my .sql file and started all over again. However, all my hyperlinks on every page still point to the live site! (I thought the sql code in the .sql file created the pages?).

    I have 350+ pages on my website but only the home page – localhost/mywebsite – opens!

    When I go into my local copy of WordPress I can see all 350+ pages (so they have imported ok!) but all the pages contain links to the live site but none of these links existed in the .sql file that I exported from the live site because I changed all the links prior to importing the file and I know I didn’t miss any as I did a search and replace and checked for the existence of ‘mywebsite.co.uk’ before running the import!

    When editing any of the 350+ pages in WordPress if I click ‘Preview Changes’ I get ‘Object Not Found. The requested URL was not found on this server’.

    I am very confused!!! HELP!!!

    Thanks in advance!

    Ade.

  53. bubblecom@hotmail.com Avatar
    bubblecom@hotmail.com

    Hello Tom, Thank you for this tutorial.

    My real site (and now the local one) is made of 3 folders for language (en, es, fr) all in httpdocs on my computer. Database has been exported/imported and “siteurl” and “home” both change to localhost/en or es or fr in “options). All 3 wp_config files have been modified for DB_host to localhost. Mu only problem when I created the “USER” was with the password. In wp_config, the ‘DB_NAME’ and ‘DB_USER’ are in plain text but ‘DB_PASSWORD’ is cripted. Shall I copy and paste this in the “Create User” password window and then click on “Generate”? because so far, I am still getting “Error establishing a database connection”. Any light in the darkness?

  54. Siya Avatar
    Siya

    Thank you! This saved me a lot of time

  55. standalone Avatar
    standalone

    Hi, thank you for this tutorial.
    But, what if I want a local copy of wordpress cms, but without duplicating the db?
    Thanks in advance!

  56. Yole Ajekigbe Avatar
    Yole Ajekigbe

    Tom,
    This is to say a big thank you for your publications. I have read some, such as -How to create a local WordPress website in windows with XAMPP; How to upload a local WordPress site; How to move your WordPress website from localhost to live server; etc and I find them all very interesting. You have done a good work and I have benefited a lot from it, though I am yet to try making any website. I think is now high time I made a WordPress website following your instructions . Thank you and regards.

  57. Adam Avatar
    Adam

    If your life changes, we can change the world, too. https://youtu.be/KOA3u6LQXxs

  58. gus Avatar
    gus

    what if i want to do the inverse porccess, i changed a lot of things locally, now i want to publish them on my live site, what should i start with? there are a million post that explain what you explained, but not a single one with the inverse proccess, help

  59. Rob Avatar
    Rob

    Thanks for the guide, very useful. One bit of info missing is at the stage of editing the database values. You say “You’ll see a list of table names like this:” however the image shows the contents of the ‘Options’ table. I think the missing step should be something like; “Then click on the table name ‘wp_comments’”

    Regards.

  60. Joris Avatar
    Joris

    Thanks for the useful article. Unfortunately, I’m having some weird problems with this.
    In step two, after copying the site files, you say that I should get an ‘error to connect to database’. Well, strangely enough my whole site is up and running.
    I think this has something to do with the config file: it connects with the online (existing) database, so connection is immediately made. When I go offline (by cutting off my WiFi) I can’t make a database connection.

    Now, the real problem is that everything on my localhost links to my live site. So everything I want to do (including logging in on localhost) redirects me to the live site (which I don’t want to do, obviously). I tried changing the database name in the wpconfig.php to ‘localhost’, but then I can’t connect to the database.

    Any idea what I’m doing wrong and (more importantly) how I could fix this?

    Thanks in advance!

    Joris.

  61. Csand Avatar
    Csand

    I’m having trouble configuring the local site at step 4 of this tutorial. It seems when I reach step 4 and attempt to import my site’s database to my local host, it gives me error code 1046. Any help here?

  62. Mahesh Yadav Avatar
    Mahesh Yadav

    Hi,

    Thanks for your helpful article. It helped me well. There are still some errors which i am facing but i will solve it my end. You solved my big problem.

    Thank you very much.

  63. Casey @ GetandKeepHim Avatar
    Casey @ GetandKeepHim

    Thanks for this!

    I was following your guide and I got the error: “establishing connection to database” and I realized you left out one step which is to ensure the database name in wp-config is the same as the database name in phpmyadmin, which solved the error for me.

    Another thing is to ensure the permalinks structure is set to “Post name” (or whatever structure on your live site) otherwise every page just links back to localhost/xampp.

  64. Miki Avatar
    Miki

    The tutorial was great…. But I can add two thing that worked for me:
    1. If you have PROBLEM connecting with database, solution is to change your (wp-config.php) USERNAME to ‘root’, DB Host to ‘localhost’or use univeral one /** MySQL hostname */
    define(‘DB_HOST’, $_ENV{DATABASE_SERVER});
    and to leave your DB Pass blank like this ” nothing between those and Connecting database problem is gone.
    2. And if you can manage opening your site offline, but you have a PROBLEM with LINKS dont opening ERROR 404, just check in Appache modules “rewrite_module” and your link will come back to live once again
    the solution is on this link http://www.wpbeginner.com/wp-tutorials/how-to-enable-custom-permalinks-in-wordpress-wamp-installation/

  65. Heber Avatar
    Heber

    Hi Tom, there is no way i could have done this (WordPress on a localhost and download my live site) with out your assistance.
    Thank you very much.
    The next thing I will have to do is upload any updates to the live STUDY site. Have you a tutorial for that also.
    Regards and thanks again, Heber

  66. David Richied Avatar
    David Richied

    Yes! Step 5 is what got me when I was trying to set up my local dev environment. Couldn’t have done it without you! Thanks!

  67. Helen Avatar
    Helen

    Great tutorial, all worked fine up to the last step where I was still having trouble connecting to the database. I tried some of the suggestions made in the comments – such as changing user to ‘root’ and host to ‘localhost’ but this didn’t work. In the end, I found a solution here: https://wordpress.org/support/topic/the-infamous-error-establishing-a-database-connection

    I replaced ‘localhost’ with the ip address 127.0.0.1 and voila – my site appeared.

    Still not sure if this is the right thing to do, but its working for now.

  68. Subhashini Avatar
    Subhashini

    Yeh! After following all the steps I am still getting an error saying “Error establishing a database connection”. Can somebody guide me through what may be the problem…?

    Thanks

  69. El Sombrero Avatar
    El Sombrero

    Didn’t work for me either…

  70. Will Johnson Avatar
    Will Johnson

    Works fine … I did get an “Error establishing database” but once I first created a database and then imported data into it, everything was hunkydory!

  71. WJC Avatar
    WJC

    Hi!
    Great tutorial. Thanks.

    I was able to solve some issues during installation expet this one. The permalinks are not working properly. All internal links open the XAMPP dashboard.
    This is what I’ve done so far, hower nothing has helped.

    1. Checked the line ‘LoadModule rewrite_module modules/mod_rewrite.so\ in httpd.conf . It was uncommented, so I left it as it was.
    2. Changed ‘AllowOverride None’ to ‘AllowOverride All’ within the default and root directory.

    What I did wrong or is there other solution. I will appreciate any suggestions.

  72. anno1313@hotmail.com Avatar
    anno1313@hotmail.com

    Hi there!
    Thanks to this tutorial my local wp site copy is running like a charm.
    Thanks to author to this wonderful share!

  73. Adarsh Avatar
    Adarsh

    I am getting the below error. Pls reply
    “This site can’t provide a secure connection”

  74. Dale Avatar
    Dale

    Thanks, this was nice and clear and the process was relatively smooth for me to implement.

    The one nagging concern I have is, during construction of a wp site, I expect changes to be recorded in the MySQL DB so those will need to be uploaded at some point. While the process described here was relatively straight forward, I would like know if there was a way of uploading the DB without any editing of the DB? Some way of syncing DB’s…

    Cheers, Dale

  75. elaine Avatar
    elaine

    how can you access your live site via ftp? i have tried filezilla but it didnt work when trying to establish connection

  76. Tony Avatar
    Tony

    Excellent Information, thanks very much.

    As a tip to make things go a little quicker, in CPanel open File Manager and then compress your directories before FTP’ing them to your local machine. They compress “super” fast on the server side and then you just need to FTP 4 file.

  77. Saud Khan Avatar
    Saud Khan

    Hi, No database appears in phpMyAdmin, do you have any idea?

  78. andrew Avatar
    andrew

    Hi. At the end of step 3 I did not get a list of databases -“You will then be presented with a selection of databases to export:” I instead got a list of tables with WP_ extensions? such as”wp_links, wp_options, etc”?

  79. Chris Avatar
    Chris

    It would be super cool if when you hit the clone button you would be given some options. I would love to be able to tell it the new URL and have ManageWP rewrite the URL before everything is downloaded. Then click download. It would be even cooler if we could figure out how to actually have ManageWP push the site to a local dev environment.

  80. Atanas Avatar
    Atanas

    Works perfectly!!!

  81. san Avatar
    san

    I was wonder, where could I find XAMP for 64bit, and why the official website has not any download ability ?

  82. Villiam Avatar
    Villiam

    Hi, thanks for the steps – which I followed. But its not working. When I type “localhost/The folders name”, I come to the site and it looks almost the same as the live one except for some buttons on the front page. But I can’t log in to the dash board, and when I click on some of the other options on my sites menu it just goes to the live version.
    You know where I went wrong?

  83. Seth Avatar
    Seth

    Is it possible to use wordpress as a local intranet only? I’ve installed it on wamp locally and can add pages but cannot edit any page content. Is this possible using the local wordpress install or is it just viewable locally and not editable?

  84. John Avatar
    John

    The guide leaves out a few important things:

    1: If the database won’t upload because it is too large, you need to go into Xampp Control Panel, under Apache>config button>php.ini. From here search for “upload_max_filesize” and change to something like upload_max_filesize=16M. Next, do the same for “upload_max_filesize” to something like upload_max_filesize=16M (just has to not be smaller than db size).

    2. In order to import the database you have to create a new database entry to then be able to import your database into. In phpmyadmin sidebar add a new database with same name as the database you are importing. Once you’ve done that, import your database into it.

  85. Isaac Peterson Avatar
    Isaac Peterson

    ok maybe I’m not understanding this correctly
    when rename the URL http://localhost/your_folder_name
    what is the folder name? is it arbitrary?

  86. tech journalists Avatar
    tech journalists

    Loving the information on this web site, you have done great job on the posts.

  87. kaidok Avatar
    kaidok

    I’ve tried and tried and tried. I’ve spent the past 3 hours stuck at the point where you import the database. Every single time I get the error that it’s too large. I have no clue how to get into the mySQLadmin (I see MySQL but no admin area) I’ve tried adjusted the limits in the ini file… NOTHING I do seems to make this work. Someone on here suggested using the “other” work arounds that are alluded to in the documentation, but I have no clue how to go about doing either of those other options as I see no other console to log into. Please please help!

  88. Jan Marie Avatar
    Jan Marie

    I followed this to a T, and now we’re at the end, many many hours later, and there is nothing but a blank WP site live on my localhost/mynewsite. I’m not clear how or if I was supposed to get all my files that I exported via http://FTP... into the new site. Was I supposed to put the files into htdocs/mynewsite? Because they’re currently all hosted at htdocs/myoldsite, though I did replace the database as directed in step 5…

  89. wallace Avatar
    wallace

    thank you for such a concise and helpful tutorial!

  90. marisk Avatar
    marisk

    Followed these instructions and downloaded the site from GoDaddy Managed wordpress to local xampp. Looks like most of it works – it renders correctly – but all my menus and page links redirect to my local xampp dashboard.

    Any thoughts ?

  91. Terry Eelekes Avatar
    Terry Eelekes

    I am using MAMP on my local server and all went well so far but when I try to login to the dashboard the page just stalls. any suggestion on what the problem is?

  92. Bernard Avatar
    Bernard

    I think I have followed all the instructions above and I have used interconnectit.com’s Search and Replace tool to change all the urls. However when I try to access my local website I get an error message. My online website uses HTTPS, so I have tried both http and https to access it locally. Using http I get “Error Establishing a Database Connection” and using HTTPS I get “Hmmm…can’t reach this page” and a further error code of “INET_E_RESOURCE_NOT_FOUND”, both using Google Chrome. I have tried specifying Require SSL and Require None when defining the privileges for the database user but this doesn’t seem to change anything. Any ideas on what I’m doing wrong please?

  93. Chaprel Avatar
    Chaprel

    I’ve followed the steps and my site goes local but the problem is it is only the index page and when i go to the other pages the local server wont recognize it.

  94. Akash Gupta Avatar
    Akash Gupta

    I am using port 81 for Apache when I surff for localhost:81/myfoldername , browser automatically redirects me to localhost/myfoldername on which my Apache is not running how to overcome this problem.. all other sites working fine on port 81.

  95. Christian Panratz Avatar
    Christian Panratz

    Hey Tom,
    just wanted to say thank you for the great article, it helped me a lot

  96. Bobby J Avatar
    Bobby J

    Works like a charm for Synology NAS too. Just once you install the WordPress on the NAS remove all the files and folders and upload the ones that you downloaded from your original installation.
    Thanks mate !!!

Leave a Reply

Your email address will not be published. Required fields are marked *