Tutorials

How to move WordPressMU

21 May 2009 · 39 comments · tagged with , ,

Today I found that I wanted to move my WPMU installation to a new domain. It doesn’t really matter why — that’s a whole other story really — but just in case you want to do the same thing, this is how I did it.

There are some caveats and other considerations before diving in and moving WPMU. You can see some of them in the comments below.

  1. Log in to phpMyAdmin where you can manage the WPMU database.
  2. Export the database to an sql file.
  3. Under the Operations tab, copy the database to another database as a backup: call it something like wpmu-backup and select “Structure and data” and “CREATE DATABASE before copying”.
  4. If you need to (I didn’t because I was using the same source folder) copy all the WPMU files into their new location.
  5. Open the exported sql file in a plain text editor (e.g. Notepad on Windows, TextEdit on Mac, or another editor of your choice) and perform a search and replace function on the old domain name, replacing it with the new domain name. Save that file.
  6. Under the Structure tab, select and drop all the tables in the WPMU database (the active one, not the backup).
  7. Import the sql file with the new domain name.
  8. Change the domain name in wp-config.php in the root of the WPMU installation.
  9. Check if anything needs changing in .htaccess (also in the root directory of WPMU); I didn’t have to change anything in this file.

phpMyAdmin

That should be all you need to do. If something just doesn’t go right and you need to revert to the old installation: put the files back where they were (if you moved or deleted them rather than just copying them), undo the changes to wp-config.php, and change the name of the new database (under the Operations tab) to something else (e.g., wpmu-new) and change the name of the backed up database to the name of the active database that the blog uses. This should restore the blogs to the way they were before, in their old location.

{ 35 comments… read them below or add one }

1 Mat Packer May 21, 2009 at 19:14

Interesting….now if you can do a user guide telling how to migrate from WP standard to WPMU that would be super! I’ve got a client who I need to migrate with minimal downtime, at this point I’m thinking I might just take them down from Sunday midday through to late that night………

2 Andrea_R May 21, 2009 at 23:39

This is great! :) The only other thing to watch out for, is if the setup uses the subdomain option, to make sure the new domain is also set up with wildcards.

@mat – there’s a step-by-step over here:
http://bavatuesdays.com/importing-a-single-wp-blog-to-a-wpmu-installation/

3 kristarella May 21, 2009 at 23:51

Mat — I would go about it one of two ways: if they’re not too fussed about post IDs and everything remaining exactly the same use the native WordPress export/import, orr export the tables from the database and import them into the WPMU database. The latter is exactly what the link Andrea gave describes, so yay!

Andrea — that’s a really good point! Thanks for pointing that out. I battled so much with subdomains on my MAMP install that I gave up, so I’m just using subdirectories.

4 Deborah Carney May 22, 2009 at 01:56

AndreaR I am trying to follow the link you posted and the WP install on that site is broken :(

5 Dr. Mike Wendell May 22, 2009 at 05:43

I’m sorry but I’m going to have to disagree with a fair amount of this. While the method given is a good start, there’s a couple of holes here.

1) The use of phpMyAdmin. Most folks quickly discover that phpMyAdmin doesn’t handle large *.sql files that well. You can usually get a decent export of them out of it;s interface but importing doesn’t usually go well. Timeouts are a big issue. We’ve seen the program miss a non charset character and wind up importing the sql commands as data. Usually either the command line or the hosting interface (they usually use command line scripts instead of working in php) would be a better way to go.

2) Use of Notepad. Same as #1 pretty much. Notepad will usually choke on files over a meg or two in size. It also saves as a default of ANSI and not UTF-8 which may also cause issues.

3) You’ll need a method of redirecting from the old site to the new one. You probably don’t need one if this is a new site but you will if this is an established site you’re moving. If you don’t, all the old inbound links will not work and you’ll have a large number of ticked off clients.

4) Search and replace the domain: This is one issue my clients and I have discussed a couple of times. Sure, the records in the options tables will need to be changed but what about the individual blog’s contents? Is it a link or just text? Do you modify a client’s content? Searching for the domain with the http:// bit on the front would probably be the way to go but then you run into a problem with the usernames within the blog urls if you;re using subdomains.

5) Replacement of the database. Have to admit that I would leave the original database alone and intact and work off of a new database. That way if anything goes wrong, you have the original still intact and ready to go. You’ll have to modify the wp-config.php file to use the new database but it’ll save you if you make a mistake somewhere.

Sorry to disagree with you,
-drmike

6 kristarella May 22, 2009 at 10:42

Deborah — try the link again, it works for me.

Mike — Liberal use of “disagree” there. Some extra things to think about for sure, and all of your points are good. I guess it depends on the situation: in my case I was moving a local install with about 18 blogs on it, each only having about 10 posts.

1. Thanks for the link I’m sure it will be very useful. This is a good consideration for a large database, I didn’t have a problem, but I will put a note in the post.
2. I have a general aversion to Windows and have barely used it in about four years. I was really just trying to illustrate what I meant by a plain text editor. I’m inclined to think that even that illustration wasn’t necessary: if someone is daring to play with WPMU I’m sure they already have a much better editor in operation.
3. Good point. Hopefully if that is a consideration in the move, the person moving their site wouldn’t need me to tell them that. All I was really trying to point out was the things that you need to do to see that WPMU works in the new location since it doesn’t support the changing of the site URL like WP does.
4. If you’re dealing with a client’s site there are a lot more considerations and a responsible web admin would need to think those through. Again, this is really just how to move it and get it working, not what are all the practicalities and ethics of moving and changing content. Another problem I had recently with a client blog (not on WPMU, just WP) they hade some URLs with www. in front and some not, so subdomains are a serious consideration there.
5. In my mind there is next to no difference between working off the original and using a new one (when there is an identical duplicate in the same process). I actually did use a new one when I moved, but in the instructions above we have both downloaded an sql file of the database as well as duplicated the database as a backup. It doesn’t make a difference to me which duplicate you choose to work with or whether you just want to make a new one, as long as there is a proper backup.

Thanks for your thoughts. While there may be more solid ways of doing this, and the things you’ve mentioned are important considerations for larger sites and sites that have been live for a while etc, the intro to the post does say “this is how I did it”. ;-)

7 Chad May 23, 2009 at 04:35

We tried changing the domain on a MU installation and went late into the night trying to figure out why only the main blog worked but none of the others. We replaced in the .sql file with a new domain that included “www” and MU choked (purged?). We needed the www at the time because we used the domain with Active Directory and email. We had to make one small core edit in wp-settings.php (just one statement!) in order for it to accept our www domain. Requiring www is a petty decision in our minds, a feature to others.

Had we installed MU with the www domain in the first place, we would have received the ‘no-www’ error notice. We didn’t see this because of the search and replace behind the scenes.

8 kristarella May 23, 2009 at 10:50

Thanks for sharing your experience Chad. That is another thing to note: realising what MU can actually run on in the first place.

9 Mike June 3, 2009 at 16:39

Hi Kristarella,

Sorry, my comment’s off topic here, just like what you did with the design of your blog and wanted to ask a general question if I may

I see you use the thesis theme for your blog, which I’m considering getting for myself. Can you tell me whether you made changes to the code to get your design or were you able to manage it all with the custom css and the adjustments thesis allows you to make from the dashboard or wherever.

In particular, I was especially curious about getting the sidebars at the bottom of the page and some other cool things you’ve done

Mike

10 priscila June 19, 2009 at 23:00

thanks, it was so useful cause i have a problem with my installation i did that and works great… really helpful

11 Amjad June 27, 2009 at 02:57

Thanks! This was just what I needed to do! :)

12 Christina Gressianu July 8, 2009 at 08:33

Thanks for this! I tried to do this a couple months ago and managed to delete my whole blog. Ugh. Wish I’d read this first

13 Derek August 27, 2009 at 15:31

Thanks mate. Worked a treat.

14 Ari September 9, 2009 at 07:44

Hey again, Kristarella!

I just moved my wordpress to a different subdirectory. Everything looks okay, expect the blog doesn’t display correctly. I’m not sure what is wrong. Any ideas?

Thanks so much!!

15 kristarella September 9, 2009 at 09:42

Ari — is this related to WPMU? The link you left in your comment info goes to a page not found and I’m not sure if your comment is related to the post, so I don’t really know where to start hypothesising.

16 proposal tugas akhir September 25, 2009 at 18:37

Thanks very much for the tutorial, i already moving my mu wordpress.

Nia

17 betterfasterstranger October 14, 2009 at 12:03

Hey Kristarella,

Thanks for the tutorial, got through it and can view my site on the new server (moving from a localhost to our work network – WPMU is for our intranet), but – I can’t get to the admin panel anymore…

Any ideas?

Cheers!

18 kristarella October 14, 2009 at 15:48

Don’t know about being unable to view the admin. I guess I would check the database in the options table and see what it thinks the URL for the blog is: in the table wp_1_options (or something other than wp_ if you chose a different database table prefix) check row 1 and row 39 (site URL and home, respectively) and see if they match.
Are you able to get into the dashboard for any of the blogs on the WPMU site? Are you only blocked out of the parent site admin?
Also, if you have plugins installed, perhaps try deleting/moving them out of the plugins folder. If one of them has settings interfering with the new address then you should be able to get in if the plugins aren’t present. Then you can add them back gradually and see how they go.

19 Ross Bennetts October 14, 2009 at 15:54

How can I do the search and replace on a multi-gigabyte sqldump?
I have access to Mac, Widnows and Linux.
Vi, TextEdit, TexWranlger, Notepad are all choking because the file is too big… I can’t image how phpmyadmin is gonna go trying to import it…

20 kristarella October 14, 2009 at 16:24

Ross — I’m not really sure. I’ve never tried this on such a large site and wouldn’t guarantee this method for it at all. You could check out the link about BigDump that Mike left before, which might help with the phpMyAdmin import limits.
The reason I downloaded the SQL file and edited it with a text editor is because MySQL seems to want you to search and replace individual tables, not whole databases. I found someone posted a PHP script for going through every table automatically. Obviously make sure everything is copiously backed up before trying such a thing. Here’s another search and replace script, which looks worth investigating.

I use Coda for editing. I don’t know if it will do files that large, but it might. It always displays a message asking if it can turn off text highlighting for files when they get large enough. Other than that it’s been ok with the files I’ve edited, but I doubt they were as large as yours. The free trial is fully functional if you want to try it.
Other editors to investigate:
Hex Fiend
Vim or macvim (I know you said you tried Vi, I’m not sure how they differ, but people seem to recommend Vim across the interwebs for large files)
CRiSP claims to be able to handle up to 8GB files.

21 betterfasterstranger October 14, 2009 at 16:37

Ah, I fixed it – realised that my wp-config missing the / in

define(‘PATH_CURRENT_SITE’, ‘/’ );

hooray !

22 Ross Bennets October 14, 2009 at 17:01

TextEdit actually did the trick eventually… it just took over 30 minutes and used 99% of my 4GB RAM… and I figured out how to get to the command line version of mysql on MAMP… I think I’m good now…
I am trying to make a duplicate version of my site so I can do some development work without battling with a poorly configured version of APC…
Thanks very much for your help…
:)

23 Holling January 9, 2010 at 03:10

Thanks for the walk-through…worked like a charm, at least once I corrected a mis-spelled domain name.

Cheers – Holling

24 Kristina February 9, 2010 at 04:36

Does this transition from domain to domain PRESERVE your plugins,, settings for everything,, so on??

25 kristarella February 9, 2010 at 07:28

Kristina — Yes, as long as you move the plugin files along with your other files all their settings etc should remain in tact.

26 Kristina February 9, 2010 at 07:41

Awesome! Thank you :)

27 Tela March 3, 2010 at 03:22

I need to move a wpmu site (biovedawellness.com) to a new host. Will this process work for that as well (domain name won’t change)?

28 kristarella March 3, 2010 at 08:05

Tela — You won’t need steps 3–6 of the tutorial then. If it’s a large site you might need to look into BigDump from the comments above to get the database into the new server’s database — I used it a couple of weeks ago, it worked really well! Other than that you’ll just need to download your whole installation from the original server and upload to the new one. As far as I know that should be it.

29 Dave Lee April 20, 2010 at 14:15

This was an AMAZING post. I almost blew up my WordPress MU install and several blogs before I found you. Thank you so much for posting this!

30 saxx143 June 16, 2010 at 07:12

I found your site very informative and I am about to take that journey. But I need to know if I need to. I had a wordpress site on my domain and then decided to do wordpressMU. Instead of exporting or what ever I just created a subdomain and recreated my site there. now i have two sites. Selectivesounds.com and multi.selectivesounds.com

What i want is to make the multi. selective…. into the main domain, Selectivesounds.com. Is it a matter of just redirecting the domain? If so will the address bar show the subfolders as selectivesounds.com or multi.selectivesounds.com?

Hope its not to confusing.

31 kristarella June 16, 2010 at 10:29

saxx143 — I’m not sure what the best approach for you is. Assuming you are shutting down what is currently on selectivesounds.com and moving the content of multi.selectivesounds.com to it, and assuming they are two different WordPress installs, multi. being WPMU, there are 2 approaches:

  1. Export multi. with the WordPress export tool and import it to selectivesounds.com
    Before doing so you should backup and then delete all the content, or do a new WP install at selectivesounds.com
  2. Use the tutorial above to move your whole WPMU install to selectivesounds.com
    Be sure to consider the impacts of a large database, you might need to use BigDump or Sequel Pro (a mac application) to handle the database instead of phpMyAdmin

If the two blogs are actually part of the same WPMU install then your safest option is to just use the WordPress export to move all the content from one blog to the other.

If you are venturing into a lot of rearranging and site wrangling you should consider that WordPress 3.0 is nearly out — the release candidate is out and is quite stable — and it’s replacing WPMU, so you might want to upgrade your WPMU to WP 3.0 or just create a new WP 3.0 install and import your content to it.

32 SaXx143 June 22, 2010 at 03:38

Hello,

I thank you so much for your advice.

I was curious now that WP MU 3.0 is out would you change any of what you told me on how to move my wordpress Mu location to another directory. (the question that I asked earlier)

33 kristarella June 22, 2010 at 09:31

saxx143 — I haven’t been able to dig deep into the workings of WP3.0 with networks enabled yet, but a cursory glance appears that it functions very similarly in terms of databases and site settings. I don’t think my advice would be different.

34 SaXx143 June 26, 2010 at 02:06

Hello,
I must start with Thank you. It definately worked. Now, I am back with another question that is off topic but I am hoping you can help me. Do you know much about buddy press or those social plugins? I have a WPMU site that I want to act as my main site and I want to have other blogs for various other areas. I would like them to function on their own but I want the social aspect of the blogs to be tied together. As of now I am on the verge of being right but I am still wrong. My sites (right now only two..trying to begin correctly) connect to each other but the second one uses the main sites theme to show activies, members, groups and so on…. would you happen to know what I am doing wrong?

Thanks in advance….

35 kristarella June 26, 2010 at 09:20

Saxx143 — I have very limited experience with BuddyPress, but what you’re saying about using the main site’s theme makes sense if your theme on the second site is not BuddyPress enabled: it would need the proper template files for displaying members etc. It’s possible if they’re not present then it will use the template files from another site on the same network that does have those files.

Leave a Comment

Want to show PHP or XHTML code in your comment? Encode it first so that WordPress doesn't strip it away.

Read the comment policy.

Previous post:

Next post: