{"id":1645,"date":"2020-02-04T23:13:31","date_gmt":"2020-02-04T22:13:31","guid":{"rendered":"https:\/\/www.languedoc121tech.fr\/?p=1645"},"modified":"2020-02-04T23:13:31","modified_gmt":"2020-02-04T22:13:31","slug":"sql-for-rewriting-wordpress-database-links","status":"publish","type":"post","link":"https:\/\/dev.languedoc121tech.fr\/?p=1645","title":{"rendered":"SQL for Rewriting WordPress Database Links"},"content":{"rendered":"\n<p>When you move a WordPress site, whether that&#8217;s from a live to a local site, or perhaps when you change the site to SSL, you will need to change the URLs in the database.<\/p>\n\n\n\n<p>There are plugins for this, but it&#8217;s easy enough to do in the database itself using a few simple SQL statements in phpMyAdmin.<\/p>\n\n\n\n<p>The three SQL statements you need are:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE wp_options SET option_value = replace(option_value, 'http:\/\/www.example.com', 'http:\/\/www.new-example.com') WHERE option_name = 'home' OR option_name = 'siteurl';\n\nUPDATE wp_posts SET guid = replace(guid, 'http:\/\/www.example.com', 'http:\/\/www.new-example.com');\n\nUPDATE wp_posts SET post_content = replace(post_content, 'http:\/\/www.old-domain.com', 'http:\/\/www.new-domain.com');<\/code><\/pre>\n\n\n\n<p>Just change the URLs and then simulate the query to test it, then run it.<\/p>\n\n\n\n<p>Done!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you move a WordPress site, whether that&#8217;s from a live to a local site, or perhaps when you change the site to SSL, you will need to change the URLs in the database. There are plugins for this, but it&#8217;s easy enough to do in the database itself using a few simple SQL statements&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"kt_blocks_editor_width":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_vp_format_video_url":"","_vp_image_focal_point":[]},"categories":[28],"tags":[96,97],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"vp_sm":false,"vp_md":false,"vp_lg":false,"vp_xl":false,"vp_sm_popup":false,"vp_md_popup":false,"vp_xl_popup":false,"1536x1536":false,"2048x2048":false,"page-title-image":false},"uagb_author_info":{"display_name":"Admin","author_link":"https:\/\/dev.languedoc121tech.fr\/?author=2"},"uagb_comment_info":0,"uagb_excerpt":"When you move a WordPress site, whether that&#8217;s from a live to a local site, or perhaps when you change the site to SSL, you will need to change the URLs in the database. There are plugins for this, but it&#8217;s easy enough to do in the database itself using a few simple SQL statements...","_links":{"self":[{"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=\/wp\/v2\/posts\/1645"}],"collection":[{"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1645"}],"version-history":[{"count":0,"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=\/wp\/v2\/posts\/1645\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.languedoc121tech.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}