Make This Tech Work (Archive)

SQL query tip - Running a WordPress site locally

2018-01-24 12:56:38

Thanks to the instructions here, I was able to run my WordPress site locally on my iMac. I did this mostly just to learn how to do it, but doing this can help with testing changes to your website before publishing it.  At a certain point in the instructions, I was instructed to execute 3 SQL queries. These are queries that would update my website's database so that it can be used locally on my computer. I wanted to see what would be changed before actually making these changes. So I executed 3 SQL SELECT queries first.

The SQL queries in the instructions

UPDATE wp_options SET option_value = replace(option_value, 'http://www.example.com', 'http://localhost/test-site') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET post_content = replace(post_content, 'http://www.example.com', 'http://localhost/test-site'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.example.com','http://localhost/test-site');

The SQL queries I ran first

SELECT option_name, option_value FROM _USD_options WHERE option_name = 'home' OR option_name = 'siteurl' ; SELECT post_content FROM _USD_posts WHERE post_content = 'http://www.example.com' SELECT meta_value from _USD_postmeta WHERE meta_value = 'http://www.example.com' In these 'SELECT' queries where I saw "http://www.example.com", I replaced it with my website, "http://makethistechwork.com". I hope that helps someone using these instructions or anyone wanting to do a simple 'SELECT' SQL query.  More help on the 'SELECT' SQL query can be found here.