How to migrate from WordPress to WordPress MU

I’m quite excited to have successfully migrated my blog from 2 WordPress blogs to just 1 WordPress MU install. I had initially set up 2 blogs running on one code-base using WP-Hive, and while I’m really impressed with the hive plugin, it’s always felt more like a hack than a true trustable upgradable solution.

My weekend began with, “Migrating from WordPress to MU can’t be that hard, can it?!” Boy, was I in for a surprise. I hope this brief post will spare you the pain I went through.

1. Download and Install

First, some good news: the README file does a great job walking you through the process of getting a blank MU install up and running. The default installation process for MU is strikingly similar to the standard WordPress install. A quick unzip of the MU files on your server, a few chmod’s, a fresh mysql database, and everything should be peachy.  But that’s the good news, what’s the bad news?

2. Importing Your WordPress Data

Now if you’re like me, you might have noticed the tempting “Import” and “Export” buttons.

Don’t touch them! These buttons are nothing more than cleverly designed distractions – little pixel sirens – they are not your solution. With my very modest 5.8 Mb export file, I had one hell of a time getting MU to import the thing.

No matter what settings I tweaked, the import timed out after 60 seconds. I changed WPMU settings, I changed PHP max upload size, max timeout, and max memory settings. I ended up splitting the file into over 30 tiny pieces, and still couldn’t get it imported.

mind. numbing.

In my dedication slash foolishness, I wrestled with it for about 6 hours split over 3 days until I finally had enough. Maybe you’ll want to wrestle with splitting xml files and tweaking random upload settings (or maybe you’re lucky enough for it to just work), but not me. There had to be a better way, and luckily there is.

3. Create a New Blog

Creating a new blog in MU is a super easy process, just click then the button. Fill out the form and away you go.

Take special note of the ID that WPMU gives your new blog. The ID is in the left most column of the blogs list.

4. Migrate Your DAta – This Time For Real!

Fire up phpMyAdmin, and take a look at your old blog’s database. You’ll want to export the following tables to a .sql file:

  • wp_comments
  • wp_links
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy

Remember that ID from step 3? Open up the .sql in your text editor of choice, and globally replace “wp_” with “wp_{ID}_” (where {ID} is your blog’s ID).

Now point your phpMyAdmin at your WPMU’s database. You’ll notice in this database that you’ll already have tables with names like “wp_1_posts”, etc, so prefix all the tables with your blog ID in them with “old_”. The only table you’ll skip is “wp_1_options”.

Now that you’ve renamed those 7 tables, upload your .sql file into your WPMU database. You should now have a table list that looks something like the image to the right.

5. Fix Author of Posts

Last step! For every author in your old blog (probably just you), create a user in WPMU (if it’s you, it’ll be the MU admin). To assign all the posts to the admin MU user, run the following command in your MU database (substitute {ID} for the blog ID):

[code lang=’sql’ line=’1′]
UPDATE wp_{ID}_posts SET post_author = 1
[/code]

6. Done!

That’s it! You’ll probably want to log into the admin console and re-enable any plugins you need, and tweak your settings again. We omitted the wp_options table, so this process doesn’t import any blog settings at all. I tried importing settings as well, but hit a wall and was plenty happy to manually fix those.

At this very moment I am enjoying 1 admin panel, 1 click install for new blogs, 1 database, and 1 codebase. Simple. Upgradable. Trustable.

Enjoy your WordPress MU powered blog!

101 thoughts on “How to migrate from WordPress to WordPress MU

  1. An excellent post! This will definitely be my how-to manual when I install WPMU. 🙂

    WP Hive and WPMU have their uses and it’s great that you found what works best for you. Thanks for the mention.

  2. Ok so how do I import data from WP -> WP (regular, not MU) without getting the 60 seconds error?

    Should I just use phpMyAdmin and try and finagle IDs and such? Will that work or will I break something?

  3. @buck

    while i haven’t tried it, migrating from WP -> WP should work the exact same – almost.

    This post assumes your staying on the same domain name / blog install URL. Sounds like you’re moving URLs as well? In that case, you may need to do a global search in phpMyAdmin for your old URL, and manually replace it with your new URL.

  4. This has just solved all my problems. I too share the sentiments mentioned at the start of this post, WordPress has the nack of sucking you in and distracting you with ‘tempting buttons’ that often dont do what you expected.

    Thanks for your help!

  5. Pingback: The Ambuscade
  6. Hi! Very nice guide!
    I have an issue and I was hoping you would have some idea on how to solve. We run an online magazine, with around 50 authors on a normal WordPress. We hadn’t used MU both for ignorance about it and because we were not expecting to expand so much so quickly. The second reason is that we do not allow the authors to log in wordpress and post the articles themselves, but we have redactors taking care of them, to ensure the quality of the articles and of their look and feel. We have anyhow 50 and more profiles, to have the names and profiles of each writer in the page of their article.
    Now the question : we want to move now to MU to create a network within the magazine, how can I move more quickly the whole list of users, with all their data in them, without having to recreate the users one by one in MU, and having to set up the author of the posts one by one? Thanks in advance!

  7. @Andrea,

    You should be able to just copy over the wp_users table, just as you would all the other wordpress tables. The WordPress Mu users table differs slightly, so you’d also need to run the following SQL command:

    ALTER TABLE  `wp_users` ADD  `spam` TINYINT NOT NULL ,
    ADD  `deleted` TINYINT NOT NULL ;
    

    But copying over tables like this would copy everything in to 1 blog inside the Mu install. You’d still have to create blogs for each user, and presumably move posts from the main blog into each user’s blog as well. <= that I'm not as sure how to do 🙂

  8. Hi ,
    I have a question!
    My current wordpress blog is at http://www.angrezy.com.
    I would like to use WordPress MU for the same domain.

    Where should i first upload the WordPress MU Folder?? Since i am already running my blog with WordPress 2.7 on same domain name.

    Eg: My existing root folder has folders like “WP-Admin” “Wp-Content” etc .
    But when i upload the folder of “WordPress MU” all my previous folders will replace with “WordPress MU” Folders??

    Please some help me out.

  9. Hi there ,

    A good tutorial , but I m wondering what if we have only 1 blog now with WP2.7 and now shifting to WPMU 2.7.

    In that case we could also link the db , username and password or our old database to a new MU installation.

    Please clarify me , if I m wrong. As I m also facing that problem, my db is also higher than wp import export tools. 🙁 .

    Waiting to for reply, thanks

  10. What about the uploaded files? I mean, if you (like me) have a lot of images uploaded through the WordPress Media Manager and inserted into the posts, you also know that the source of these images is the absolute path in your WordPress installation.

    In a classical WordPress installation, the path is something containing the following:

    “wp-content/uploads/filename”

    In a WordPress Mu blog this becomes something like

    “wp-content//files//filename”
    or
    “files//filemae”

    When you migrate your posts, how do you change the references to all the images and/or other files you have uploaded on the previous installation?

    I hope I was clear.

    Cheers,

    V.

  11. Yeah thats why , I dropped the idea of migration, and thought it is not a good idea for me. As of now I added some more blogs to my network by adding wp on subdomain and created diffrent mysql db.

    But even if I attempted to go on to WPMU it will not affect me a lot bcz.. Currently I m having more than 500 post and all Images are loaded on google blogspot server or on photobucket or even in flicker address. 🙂 As I earlier I used the blogger.com platform to publisize my views. But now I shifted to WP .

    Will think in future, when I will have a great userbase and too many content writer 🙂

  12. as far as moving file uploads, i believe all i did was move the /uploads directory to wp-content/blogs.dir/1/files and everything just worked.

  13. Pingback: Kuamadomo
  14. This needs to be posted on the official WordPress site. Simplest, best solution I have found. I spent so much time trying to get their crappy importer to work. A million thanks for sharing this.

  15. Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language 😉
    See you!
    Your, Raiul Baztepo

  16. One Tip, Make sure you remove the brackets from the last step where you change the post author. This should help some save a few headaches.

  17. Hi Adam!
    We have finished the transition from wp to wpmu, which for us included quite a few changes in the database.
    anyway, now we are stuck with a final problem: when trying to change the name of a category… the category disappears and a (random?) tag goes at its place, becoming category! We are so stuck right now… any idea on what could this depend on?

  18. Andrea, sorry, no idea on the category/tag problem. I haven’t seen that one. Hopefully one of the other commenters has an idea what might be going wrong?

  19. Nice tutorial! Helped me a lot. I’d like to add that if you’ve uploaded files into the original wordpress site, the content is stored in: ~/wordpress/wp-content/uploads

    And in wordpress mu this corresponds to: ~/wordpress-mu/wp-content/blogs.dir/{Blog ID}/files

    I copied everything under ~/wordpress/wp-content/uploads to ~/wordpress-mu/wp-content/blogs.dir/1/files

    I also used the following SQL command to update the post contents in the database: update WP_1_POSTS set POST_CONTENT = replace(POST_CONTENT, ‘wordpress/wp-content/uploads’, ‘wordpress-mu/wp-content/blogs.dir/1/files’)

    Seems to be working so far 🙂

  20. @eddihughes, I didn’t try moving the usersmeta since it wasn’t important in my case and I didn’t want to risk it. I’d try moving everything over except users+meta, then backup, then move users and meta and see how it works out. and better yet, report back here so we all know! 🙂

  21. @adam

    It actually migrated without any problems (from what I can tell so far).

    In addition, I decided to make a custom query to assign the users to all the blogs.

    For example, :

    INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES

    (377, 6, ‘wp_1_capabilities’, ‘a:1:{s:6:”author”;b:1;}’),
    (378, 6, ‘wp_1_user_level’, ‘2’),
    (379, 7, ‘wp_1_capabilities’, ‘a:1:{s:6:”author”;b:1;}’),
    (380, 7, ‘wp_1_user_level’, ‘2’),

  22. Thanks for this! I’m running into roadblocks with the users/usermeta part of our pending migration … eddihughes may be onto a fix, but it is still a bit Greek to me.

    Can anyone help me with a query that will make sure all of our 700+ users become subscribers to wp_1? I also have a second admin that isn’t getting copied over with admin capabilities.

    Many thanks in advance!

  23. FYI: For anyone who might care, here’s the query I was looking for thanks to Andrea and Ron at wpmututorials.com …

    UPDATE wp_usermeta SET meta_key = 'wp_1_capabilities' WHERE meta_key = 'wp_capabilities'

  24. Re: Andrea (http://adamwulf.me/2008/10/04/how-to-migrate-from-wordpress-to-wordpress-mu/#comment-4358)

    I had the exact same problem last night on my localbox.

    I kept on importing the same SQL file and somehow it fixed itself.

    There’s something messed up in the wp_terms, wp_term_relationships, wp_term_taxonomy and possibly wp_links tables.

    At least this was the case for me.

    The link categories were showing the wrong count. That’s when I knew something was up. It still shows the wrong count, but at least the categories / tags are working for me again.

    Sorry if that doesn’t help!

  25. Hey, when exporting the tables, am I exporting structure also, or just the content?? Also, in phpmyadmin, is there a way to export just the tables I want or do I wave to dump the whole data base and delete un-needed tables manually? Thanks for your help!

  26. Thanks for this very useful information.
    Can you advise me if the process is the same if wanting to migrate 5 existing WP installs on subdomains to MU also?

    thanks

  27. Paul, yes this process should work for migrating any number of blogs into WPMU. The last step – where you update the author id – might be a little different if you’re migrating many blogs with different authors. In that case, you’d need to add a user for each author and update to that user’s id.

  28. I have a problem substituting the author from my old blog posts.

    I was the only author previously and therefore author ID = 1

    my old table prefixes were: customprefix_
    and I’ve changed them to: customprefix_{2}_

    I’ve tried running the sql command:
    UPDATE people_{2}_posts SET post_author = 1

    I’ve tried the suggestion by T-Pain to remove the {} and still no joy. The sql error says that its a syntax error.
    Do you have any ideas? Thanks in advance.

  29. i tried all the steps, though i didn’t get any errors..
    My case was the same as above (as Paul)

    On
    UPDATE wp_{ID}_posts SET post_author = 1
    which for me was wp_6_post SET post_author=1
    returned… succesful .. but said no rows changed !!

    Should that be the case ?

    Oh BTW i don’t see the new user in my installation 🙁 !!!

  30. ooOps !!!
    Embaraasing… It did work 🙂
    Thank you so much.. !!

    PS : It works well for migrating existing wordpress installation as a member BuddyPress blog too

  31. It worked except for the images. I moved the the /uploads directory to wp-content/blogs.dir/2/files. The image still does not show up.
    Any ideas/suggestions ?

  32. @aajkaal … You moved the files, but now need to update all the image links. Search your database and replace all instances of the old url pointing to the previous image directory to the new location. Worked for me. As always, backup, backup, backup. Hope this helps.

  33. Its nice to see you upgrading to MU at this stage. Its always good to be prepared big for the future. However the real ease of Wp-MU comes when you manage more than 10 blogs and a big list of authors.

  34. Nice tutorial, thanks 🙂

    However, be careful on the 4th step when replacing “wp_” with “wp_{ID}_”, it also replaces some fields value like meta_key field in wp_*_postmeta and wp_*_usermeta tables. So you’ll probably have to use the following queries (examples with blog site 1) after the restoration:
    UPDATE wp_1_postmeta SET meta_key = ‘_wp_1_attachment_metadata’ WHERE meta_key = ‘_wp_attachment_metadata’

    UPDATE wp_1_usermeta SET meta_key = ‘_wp_1_attached_file’ WHERE meta_key = ‘_wp_attached_file’

    and so on… 🙂

  35. Thanks for the post. Migrating data is such a bear and there aren’t enough detailed tutorials, like this one, to help you through it.

  36. This is in response to a comment I made a few months ago and to Andrea’s comment.

    This is a big word of warning for those importing regular WP blogs via PHPMyAdmin / mySQL.

    Watch out of WPMU’s wp_sitecategories table!

    If you have a ton of categories and tags, WPMU will not detect these categories since you’re using the DB, you’ll run into problems when you need to add new categories or tags.

    I used this method to import a regular WP blog over to WPMU and read what happened to me here:
    http://mu.wordpress.org/forums/topic/15553

    Best to use Ron’s Advanced Export plugin and re-import in the WordPress admin area.

  37. I have been planning to migrate my WP Blog site to WPMU but I am afraid will this hurt my SEO Credit? Please someone throw some light on the issue…

  38. Hello, how are you after more than 1 year of WPMU?

    I’ve read it is more strict on HTML, removing ids and classes from elements.

    What it worth it? Would you still do it now if you hadn’t? Do all plugins work fine??

    I have 2 blogs and I plan on founding a new one. It would be much more scalable if I had them all together. It is already hard to keep 2 installations updated, 3 will be a nightmare!

  39. It’s a little confusing, but if you have more than a couple WP sites I’d say it’s worth it. Just be wary of wordpress-mu/wp-includes/kses.php file, it restricts the tags allowed in your WP-mu sites. This file gets wiped each time you do a WP upgrade.

    Specifically look at this section:

    * Kses global for default allowable HTML tags.

  40. Well my theme overwrites $allowedtags 🙂

    In WordPress I’m able to use anything in posts and in my comments, and also in comments that I edit, while visitors comments are filtered by $allowedtags.

    About posts, it’s done by wp_filter_post_kses(), which is called in some places if if ( !current_user_can('unfiltered_html') ) 😀

    Does WP MU supports this rule too?

  41. Beautiful! I have but one thing to add. If you store pictures locally, as WP defaults to doing, you need to change the URL of the pictures. The easiest way to do this is export the _posts SQL file and do a find and replace with the new link path.

  42. Amazing! Finally did it! Its worth noting my little nightmare though…

    Basically i was getting various errors on the import such as;

    CREATE TABLE `wp_1_comments` ( `comment_ID` bigint(20) unsigned NOT ‘ at line 1
    …..
    Documentation #1064 – bigint(20) unsigned NOT ‘ at line 1

    The trick is to not have any of the various export options on such as the Auto increment in the STRUCTURE and the complete and extent inserts in the DATA options. Im not sure exactly which one was causing the problem but in hindsight you only need the tables required for the import and none of the fancy (perhaps useful in other circumstances) options on export. Hope this saves someone else some time!

    Cheers again guys, even the comments were very useful!

  43. Is MU translated into Spanish? and is it able to use a plugin to make it bilingual? and switch back and forth? qtranslate has been a Godsend for us on the regular WP and not sure if I want to migrate until MU catches up.

  44. This is all well and good, but you also had a big database. I just migrated a small site from single-user to MU, and the import/export thing worked with a single PHP memory tweak.

    Anyway, soon enough they’ll both be the same system anyway.

  45. hello. i have 5 wordpress blogs hosted on individual domains on my VPS. I have now installed the MU and would like to know how to migrate existing blogs to it, preserving their URLs. I can follow the instructions above, but do not understand how to preserve the original URL whilst deleting the old wordpress at the same time.

    thanks in advance

    kromcuich

  46. Pauline makes a good point (but I think her solution is reversed?). Instead of the global replace, I did one for each of the 7 table names. e.g. %s/wp_comments/wp_3_comments/g

  47. I just did the export -> import thing to move from a WP2.9 to a WP3 (beta) with MU enabled. Worked like a charm. 🙂

  48. This may need to be updated for WP 3.0 – I wanted to point out to the author that this shows up on Google search and a lot of people end up on it for information. Make sure to update or at least link to a new article for SEO purposes! 😀

  49. I’m surprised nobody mentioned this, but you could have solved the timeout issue with either:
    php:
    ini_set(‘max_execution_time’, 600); // 10 minutes
    -or-
    set_time_limit(0); // forever

    OR, via php.ini:
    max_execution_time = 600

  50. > We omitted the wp_options table, so this process
    > doesn’t import any blog settings at all. I tried
    > importing settings as well, but hit a wall

    Some hints to break this wall?
    Any tips or link is welcome
    Thank you in advance
    Diego

Leave a Reply

Your email address will not be published. Required fields are marked *