{"id":1450,"date":"2013-09-27T07:23:01","date_gmt":"2013-09-27T07:23:01","guid":{"rendered":"http:\/\/www.websitedesignwebsitedevelopment.com\/?p=1450"},"modified":"2014-03-19T09:13:37","modified_gmt":"2014-03-19T09:13:37","slug":"how-to-merge-two-databases-in-wordpress","status":"publish","type":"post","link":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/","title":{"rendered":"How to merge two databases in WordPress?"},"content":{"rendered":"<h2>How to merge two databases in WordPress?<\/h2>\n<p>You must be surprised that what does it mean by merging two databases in WordPress and why it is required? In fact, i faced a challenge few days ago where new database was updated with respect to the settings, themes and other installation stuff but the old database was having genuine posts, drafts and even pages which were mistakenly not imported to the new copy of WordPress. So the challenge was to keep both copies but to make two databases work together was not practically easy and recommended. What i did, analyzed number of posts in both databases and found the old database posts in bulk. Simply renamed the two tables &#8220;posts and postmeta&#8221; from old DB and imported to the new database. Only two tables are imported to the new DB. Then run the following mysql query.<\/p>\n<p><code>&lt;?php<br \/>\n$e = mysql_query(\"<br \/>\nSELECT<br \/>\np.*<br \/>\nFROM<br \/>\nwp_posts_old p<br \/>\nWHERE<br \/>\npost_status = 'publish'<br \/>\n\");<br \/>\nif(mysql_num_rows($e)&gt;0){<br \/>\nwhile($f=mysql_fetch_object($e)){<br \/>\necho $f-&gt;ID.'&lt;br&gt;';<br \/>\n\/\/INSERT INTO NEW DB AS A POST<br \/>\n}<br \/>\n}<br \/>\n?&gt;<\/code><\/p>\n<p>By this query, posts from the old DB is simply inserted to new DB. You can copy the uploads directory to the new DB as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to merge two databases in WordPress? You must be surprised that what does it mean by merging two databases in WordPress and why it is required? In fact, i faced a challenge few days ago where new database was updated with respect to the settings, themes and other installation stuff but the old database [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1463,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1450","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to merge two databases in WordPress?<\/title>\n<meta name=\"description\" content=\"Merging two WordPress databases with mysql query.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to merge two databases in WordPress?\" \/>\n<meta property=\"og:description\" content=\"Merging two WordPress databases with mysql query.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"AndroidBubble Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-27T07:23:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-03-19T09:13:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png\" \/>\n\t<meta property=\"og:image:width\" content=\"151\" \/>\n\t<meta property=\"og:image:height\" content=\"151\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Fahad\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fahad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\"},\"author\":{\"name\":\"Fahad\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"headline\":\"How to merge two databases in WordPress?\",\"datePublished\":\"2013-09-27T07:23:01+00:00\",\"dateModified\":\"2014-03-19T09:13:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\"},\"wordCount\":178,\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png\",\"articleSection\":[\"Wordpress\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\",\"url\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\",\"name\":\"How to merge two databases in WordPress?\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png\",\"datePublished\":\"2013-09-27T07:23:01+00:00\",\"dateModified\":\"2014-03-19T09:13:37+00:00\",\"author\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"description\":\"Merging two WordPress databases with mysql query.\",\"breadcrumb\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage\",\"url\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png\",\"contentUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png\",\"width\":151,\"height\":151,\"caption\":\"merge ahead, merge db, merge database, merge sign\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/androidbubble.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Website Development\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Frameworks\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Wordpress\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to merge two databases in WordPress?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\",\"url\":\"https:\/\/androidbubble.com\/blog\/\",\"name\":\"AndroidBubble Blog\",\"description\":\"Articles &amp; Posts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/androidbubble.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\",\"name\":\"Fahad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"caption\":\"Fahad\"},\"sameAs\":[\"http:\/\/www.androidbubbles.com\/\",\"https:\/\/x.com\/phpFlex\"],\"url\":\"https:\/\/androidbubble.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to merge two databases in WordPress?","description":"Merging two WordPress databases with mysql query.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"How to merge two databases in WordPress?","og_description":"Merging two WordPress databases with mysql query.","og_url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/","og_site_name":"AndroidBubble Blog","article_publisher":"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453","article_published_time":"2013-09-27T07:23:01+00:00","article_modified_time":"2014-03-19T09:13:37+00:00","og_image":[{"width":151,"height":151,"url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png","type":"image\/png"}],"author":"Fahad","twitter_misc":{"Written by":"Fahad","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/"},"author":{"name":"Fahad","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"headline":"How to merge two databases in WordPress?","datePublished":"2013-09-27T07:23:01+00:00","dateModified":"2014-03-19T09:13:37+00:00","mainEntityOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/"},"wordCount":178,"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png","articleSection":["Wordpress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/","url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/","name":"How to merge two databases in WordPress?","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png","datePublished":"2013-09-27T07:23:01+00:00","dateModified":"2014-03-19T09:13:37+00:00","author":{"@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"description":"Merging two WordPress databases with mysql query.","breadcrumb":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#primaryimage","url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png","contentUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png","width":151,"height":151,"caption":"merge ahead, merge db, merge database, merge sign"},{"@type":"BreadcrumbList","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-merge-two-databases-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/androidbubble.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Website Development","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/"},{"@type":"ListItem","position":3,"name":"PHP Frameworks","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/"},{"@type":"ListItem","position":4,"name":"Wordpress","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/"},{"@type":"ListItem","position":5,"name":"How to merge two databases in WordPress?"}]},{"@type":"WebSite","@id":"https:\/\/androidbubble.com\/blog\/#website","url":"https:\/\/androidbubble.com\/blog\/","name":"AndroidBubble Blog","description":"Articles &amp; Posts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/androidbubble.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7","name":"Fahad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","caption":"Fahad"},"sameAs":["http:\/\/www.androidbubbles.com\/","https:\/\/x.com\/phpFlex"],"url":"https:\/\/androidbubble.com\/blog\/author\/admin\/"}]}},"views":812,"jetpack_featured_media_url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2013\/09\/merge.png","_links":{"self":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/comments?post=1450"}],"version-history":[{"count":3,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1450\/revisions"}],"predecessor-version":[{"id":1547,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1450\/revisions\/1547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media\/1463"}],"wp:attachment":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media?parent=1450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/categories?post=1450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/tags?post=1450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}