{"id":6791,"date":"2021-07-28T10:39:42","date_gmt":"2021-07-28T05:09:42","guid":{"rendered":"https:\/\/www.skynats.com\/?p=6791"},"modified":"2025-05-23T16:48:22","modified_gmt":"2025-05-23T11:18:22","slug":"change-wordpress-site-url-in-database-using-command-line","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/change-wordpress-site-url-in-database-using-command-line\/","title":{"rendered":"How To Change the WordPress Site URL In Database using Command-line"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Most of us are familiar with WordPress domains. WordPress uses MySQL database to store its data including its site and home URLs. In some cases, we need to change the WordPress site URL in the database also.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, while we doing the migration of WordPress sites from one server to another server, we need to change the old WordPress site URL in the MySQL database to the new one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can add the home and site URL of WordPress using the <strong>wp-config.php <\/strong>file. But it is relevant to change the site URL in the database.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"has-inline-color has-primary-color\">Steps for changing the WordPress Site URL in the database using CLI <\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We can find your WordPress domain&#8217;s database details from <strong>wp-config.php<\/strong> file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This file will be located in the document root of your domain.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can follow the given steps to change the WordPress URLs including the WordPress site URL in the MySQL database.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Log into the Mysql prompt.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p\npassword:<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Select your WordPress database.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql &gt; show databases;\nmysql &gt; use wordpress_db;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Chnage the WordPress URLs in the database using the given commands.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB &#91;<meta charset=\"utf-8\">wordpress_db]&gt; UPDATE wp_options SET option_value = replace(option_value, 'https:\/\/old_wordpress_url', 'https:\/\/new_wordpress_url') WHERE option_name = 'home' OR option_name = 'siteurl';\n\n\nMariaDB &#91;wordpress_db]&gt; UPDATE wp_posts SET guid = replace(guid, 'https:\/\/old_wordpress_url','https:\/\/new_wordpress_url');\n\nMariaDB &#91;wordpress_db]&gt; UPDATE wp_posts SET post_content = replace(post_content, 'https:\/\/old_wordpress_url', 'https:\/\/new_wordpress_url');\n\nMariaDB &#91;wordpress_db]&gt; UPDATE wp_postmeta SET meta_value = replace(meta_value,'https:\/\/old_wordpress_url','https:\/\/new_wordpress_url');\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can replace the old_wordpress_url and new_wordpress_url with your WordPress URLs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"246\" sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM-1024x246.png\" alt=\"\" class=\"wp-image-6796\" srcset=\"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM-1024x246.png 1024w, https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM-300x72.png 300w, https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM-768x184.png 768w, https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM-1536x368.png 1536w, https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM-1200x288.png 1200w, https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/Screenshot-2021-07-27-at-11.28.24-AM.png 1780w\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">now you can able to access the WordPress site using the new updated URL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also change the home and site URL of WordPress using the wp_options table through the PhpMyAdmin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are still getting errors while updating the WordPress URLs, OUR <a href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"color:#0572a9\" class=\"has-inline-color\">technical team<\/span><\/a> will help you to resolve the issue within a short period.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of us are familiar with WordPress domains. WordPress uses MySQL database to store its data including its site and home URLs. In some cases, we need to change the WordPress site URL in the database also. For example, while we doing the migration of WordPress sites from one server to another server, we need [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,300,282],"tags":[623,622],"class_list":["post-6791","post","type-post","status-publish","format-standard","hentry","category-blog","category-database","category-wordpress","tag-change-wordpress-url","tag-set-base-url-in-wordpress"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=6791"}],"version-history":[{"count":1,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6791\/revisions"}],"predecessor-version":[{"id":14947,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6791\/revisions\/14947"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=6791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=6791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=6791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}