Is it possible just by using wp-cli to migrate one multisite instance to single site?

All we need is an easy explanation of the problem, so here it is.

It took me great time today to convert one site from to from WordPress multiste installation to normal WordPress installation (read: singlesite).

Since I started using wp-cli recently I thought it will be possible to do it only with wp-cli.

I used wp-cli to export a database. Since my instance was prefixed as: wp_9_

I used the code like this:

wp db export --tables="wp_users, wp_usermeta, wp_9_posts, wp_9_comments, wp_9_links, wp_9_options, wp_9_postmeta, wp_9_terms, wp_9_term_taxonomy, wp_9_term_relationships, wp_9_termmeta, wp_9_commentmeta" 

While I later found I should use something like this:

wp db export --tables=wp_users,wp_usermeta, $(wp db tables --all-tables-with-prefix 'wp_9' --format=csv --allow-root) --allow-root

For those not using the #

wp db export --tables=wp_users,wp_usermeta, $(wp db tables --all-tables-with-prefix 'wp_9' --format=csv) 

Then I set:


But I faced the problem: posts, guids, and meta not updated…
Usually I never do the next step since it just works in numerous instances.

But I was forced to do the following:

UPDATE wp_posts SET post_content = replace(post_content, '', '');
UPDATE wp_posts SET guid = replace(guid, '', '');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'', '');

Even further, I needed to update the uploads path, in the post content and even in the post_meta, since on mulitsite the uploads path was /uploads/sites/9/ while on a single site only /uploads/.

This should also reflect in the posts and post meta like this:

UPDATE wp_posts SET post_content = replace(post_content, '/uploads/sites/9/', '/uploads/');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'/uploads/sites/9/', '/uploads/');

After this step, I manually copied files from /uploads/sites/9/ folder to the /uploads/ folder of the new WordPress instance on the same server using the cp command. Sadly, I haven’t even considered wp-cli for that.

I am asking is it possible to automate this processes entirely using wp-cli?
It would be a great helper next time.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Try using the 10up/MU-Migration command:

Method 2

If your multi-site install only has a small number of subsites, you might find it easier to just use the export and import tools from the administration area.

For each site in the multi site install, you can download an export file that contains blog posts, pages, users, comments etc. Then you can import all these into the same single site. Might be easier than fiddling with the database…

Method 3

Instead of doing those MySQL UPDATE commands you can use WP-CLI’s wp search-replace command.

Example: wp search-replace '' ''

This is a serialisation-safe search and replace, so your meta won’t get borked.

More info at

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply