{"id":604,"date":"2021-03-25T10:47:32","date_gmt":"2021-03-25T10:47:32","guid":{"rendered":"https:\/\/mklasen.com\/?p=604"},"modified":"2022-01-20T00:31:28","modified_gmt":"2022-01-20T00:31:28","slug":"moving-a-multisite-database-errors-site-not-found","status":"publish","type":"post","link":"https:\/\/mklasen.com\/moving-a-multisite-database-errors-site-not-found\/","title":{"rendered":"Moving a multisite: Database errors & site not found."},"content":{"rendered":"\n
Moving a multisite doesn’t always go with the ease you expect. I usually do this in two steps:<\/p>\n\n\n\n
When your files are ready and your new environment is configured it’s time to import the database. My preference goes to using WP-CLI for this. Copy over the database and run When you’re moving\/copying to a different domain, you also have to run database replacement scripts:<\/p>\n\n\n\n Then it’s time to load your website, and you’re presented with a big fat:<\/p>\n\n\n\n Also, the wp-cli commands fail to run, showing errors like: Error: Site ‘newdomain.staging.com’ not found. Verify DOMAIN_CURRENT_SITE<\/em> matches an existing site or use Right.. so, there’s still something in the database that is not replaced.. You’ll find out when running: `wp db query “SELECT * FROM wp_blogs”`<\/p>\n\n\n\n This clearly shows that the domains of these sites are not replaced, because they don’t include https, so let’s run the command below to confirm the fix:<\/p>\n\n\n\n Happy with the output? Then let’s run it without –dry-run:<\/p>\n\n\n\n Moving a multisite doesn’t always go with the ease you expect. I usually do this in two steps: Export the database Deploy\/copy\/sync the files to my new (staging) server When your files are ready and your new environment is configured it’s time to import the database. My preference goes to using WP-CLI for this. Copy […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\nwp db import ~\/_sql\/database-export.sql<\/code>.<\/p>\n\n\n\n
wp search-replace \"https:\/\/olddomain.com\" \"https:\/\/newdomain.staging.com\" --all-tables<\/code>
And repeat this for your other subsites:wp search-replace \"https:\/\/sub.olddomain.com\" \"https:\/\/sub.newdomain.staging.com\" --all-tables<\/code><\/p>\n\n\n\n
Error establishing a database connection<\/h3>\n\n\n\n
--url=
wp search-replace olddomain.com newdomain.staging.com wp_blogs --dry-run<\/code><\/p>\n\n\n\n
The fix<\/strong><\/h2>\n\n\n\n
wp search-replace olddomain.com newdomain.staging.com wp_blogs<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"