• Skip to main content
  • Skip to primary sidebar
  • Home
  • Blog
  • VBA Programming
  • Open-Libre Office
  • Web Stuff
  • Videos
    • VBA Articles
    • LibreOffice And Open Office
  • Excel VBA Glossary
  • About
  • Contact

My Best Stuff Is In The Newsletter

No charge. No spam. Unsubscribe anytime.

Submitting...

How To Backup, Mirror And Run Your WordPress Website Locally

In this tutorial I show you how to download a wordpress website on your local computer and run a mirror copy of it there.

This gives you the the ability to test out website ideas privately or ensure that you have a plan B if your website get’s hacked.

The video below gives you a "look over my shoulders" view as I walk you through the steps.

Sign up below and get notified when new Business Programmer web related blog or video tutorials are created.

Submitting…

Setup WordPress Locally – Steps in Brief

The following steps are covered in detail in the video above.

  1. Get Mamp from https://www.mamp.info this gives you a complete php, mySql and Apache enviornment on your Mac or PC.
  2. Use a filemanager like FileZilla to backup your live site to you hard drive.

    You could look into plugins for this backup process, however I prefer this way.

    This saves you having to redo all your customisations.

  3. Create a local wordpress mySql Database and User, these can have the same names as the database on your live site, or they can be different.

    Database and login details are stored in wp-config.php which is normall stored in the root (top level) directory of your website.

  4. Download your WordPress database using for example phpMyAdmin withn your CPanel Area, Bluehost Web Hosting (affiliate) provide a fully featured cpanel.

    Choose the export tab and go with the "Sql" file option, this will result in a file like "YourDatabaseName.sql".

    Download the file by clicking "Go".

  5. Import the sql file downloaded in the previous step into your database created in step 3 above using the "import" tab in phpMyAdmin.
  6. Execute the Sql queries listed further down the page using the "sql" tab in phpMyAdmin.

SQL To Change URL in you WordPress mySql Database

In order for everything to work some changes will need to be made to your LOCAL mySql database, in order to update it for you new LOCAL user and for the fact that the web address of you site has changed to your local machine.

The following four update queries handle the URL (web address) changes to your database

Note do NOT use trailing backslashes in your web addresses, wordpress does not like those.

update wp_options 
set option_value = replace(option_value, 'http://www.YourLiveSite.com', 'http://localhost:8888')
where option_name = 'home' or option_name = 'siteurl'
update wp_posts 
set guid = replace(guid, 'http://www.YourLiveSite.com', 'http://localhost:8888')
update wp_posts 
set post_content = replace(post_content, 'http://www.YourLiveSite.com', 'http://localhost:8888')
update wp_postmeta 
set meta_value = replace(meta_value, 'http://www.YourLiveSite.com', 'http://localhost:8888')

This final query ensures that the user you created can use the database, this is the user id that wordpress uses in it’s wp-config.php file. Note the use of the "back quote" here rather than the simple single quote.

grant all PRIVILEGES ON `YourDatabaseName`.* to `YourNewUser`@`local` 

Verify Web Address Has Changed In Database

Finally you may need to verify that the changes you made to the site url in your database have actually happened, this can be done with the following three queries.

select option_value from wp_options where option_name in('siteurl', 'home')

select guid from wp_posts

select meta_value from wp_postmeta where meta_value like 'http://%'

You should now be good to go!

Sign up below and get notified when new Business Programmer web related blog or video tutorials are created.

Submitting…

Filed Under: Wordpress Tagged With: html

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Free Training Videos

Make VBA Listbox Work as Database Grid

Image

Ulitmate Excel VBA Advanced Filter Tutorial

Click video and press f for full screen or watch on YouTube

Dynamically Link Images to LibreOffice Base Form

Click video and press f for full screen or watch on YouTube

Create Database with LibreOffice Base

Click video and press f for full screen or watch on YouTube

Create VBA Form In Excel

Click video and press f for full screen or watch on YouTube

Affiliate Disclamer

We hope you love the products we recommend! Just so you know, we may collect a share of sales or other compensation from the links on this page.
Thank you if you use our links, we really appreciate it!

Terms Of Service | Privacy Statement | Copyright © 2024 BusinessProgrammer.com.