WordPress Tutorial: Multiple WordPress Installations Using a Single Database

Teli Adlam —  May 22, 2008

Sometimes more than one WordPress installation is necessary on a single site and WPMU would be overkill, or sometimes a hosting provider limits the number of available databases per account, or maybe you just want to keep things more organized rather than have a bunch of databases scattered everywhere. In any case, you’ll want to install multiple instances of WordPress, each one using the same database.

Luckily, this is quite simple to do, but you must install WordPress manually in order for it to work properly. A majority of the one click installations (most common is Fantastico) do not allow you to specify the prefix to use and this is absolutely necessary to be met with success.

During the installation process*, when it comes time to modify your wp-config.php file (or on the WordPress config options screen), make sure that you change the default wp_ prefix to something different.

WordPress Config File - Change Prefix

I prefer using an identifier for the specific blog that WordPress is being installed on. For instance, if I were installing it for the OptiNiche website, I would use something similar to wpon_ (i.e. WordPress OptiNiche).

When it comes time to install another blog using the same database, be sure to repeat the steps being certain to replace the wp_ prefix with something unique for the installation.

That’s really all there is to it!

* If you’re not already familiar with the manual WordPress installation process, I highly recommend watching my WordPress installation video tutorial.

Teli Adlam

Posts

32 responses to WordPress Tutorial: Multiple WordPress Installations Using a Single Database

  1. Awesome stuff you’ve been posting these days, Teli.

    THANKS ;-) Robert

  2. Thanks for the quick, low down tip.

    Will have to give this a try when the time comes.

  3. Teli,
    Could you give me an example of when I might want more than one WordPress installation for a website, and use only one shared database?
    Thanks,
    Rich

  4. Hi Rich,
    You’d want to use a single database if:
    1. Your host limits the number of databases you can create.
    2. You have quite a few blogs and rather than create 20 databases, it’s much easier to maintain/back up a single one. (Trust me, I know.)
    3. If you have more than WordPress installation on a single site and you’d like to organize your databases based on website as opposed to WordPress installations.

    I’m sure there are other reasons to use a single database, but those are the ones which jump out at me.

    ~ Teli

  5. Thanks for the reply Teli-
    I’m a newbie, just getting started with WordPress, blogging, etc with the goal to have multiple sites/blogs about various, often unrelated, topics. Ultimately I want to make some money with my blogs too.

    I was under the impression that different blogs, on different topics, etc, needed a separate database for each. For instance, to monitor site traffic to each blog? Also, is there a possiblity of information for one blog somehow being displayed on another blog using the same database?

    Finally, when you have a choice, do you prefer a single shared database over one for each blog? (I guess that you do).

    Pardon my ignorance!
    Thanks again,
    Rich

  6. Hi again Rich

    I was under the impression that different blogs, on different topics, etc, needed a separate database for each. For instance, to monitor site traffic to each blog? Also, is there a possiblity of information for one blog somehow being displayed on another blog using the same database?

    Short answer, nope. Your site traffic stats don’t necessarily interact with your database–depending on the tool you use. Besides a WordPress plugin (which would still use that particular blog’s WP DB tables anyway), the stats would be stored outside of your database or in its own set of tables. And no, as long as you remember to change the prefix for each installation, you don’t need to worry about information being shared between blogs.

    Finally, when you have a choice, do you prefer a single shared database over one for each blog?

    Well, it truly depends on my ultimate purpose for the website itself (for instance, if I plan to build it into something huge, then I’ll use a separate DB), but in general, I prefer to use a single DB for all my blog sites. I find it’s much easier to keep track of that way.

    ~ Teli

  7. Teli,
    i want to have 3 column and 2 column pages on my blog. i have a neat theme which goes in two versions (3c, 2c).

    is your solution the way to go for making this possible?
    is it possible at all?

    all the best,
    adam (@wembley on twitter)

  8. Hi Adam,
    If I understand you correctly, then no this solution wouldn’t work for you. And yes, it is possible, however, it’s wholly incumbent upon your theme.

    You’d need to customize your theme so that it will show/hide the third column depending on which page is being viewed. I recommend reading up on WordPress conditional tags for a better understanding.

    I hope that gets you pointed in the right direction.

    ~ Teli

  9. A friend of mine use that feature because all he needs is to backup one database to save the entire blogs’ data.

    I prefer each blog has its own database though.

  10. I did this a month back and it works great, just today I updated my hosting which now offers more databases and I would like to delete my old attached install and start fresh which brings me to my question:

    How can I uninstall one of the multiple instances without destroying the whole blog?

  11. This may seem like a strange question, but is it possible for WordPress and WordPress MU to share a database? I want to install MU on a site that has a pre-existing WP blog.

  12. Hello Shannon,
    Yes, just make sure they have a distinct prefix. Open up the MU config file and make sure to change it to something other than ‘wp_’; ‘wpmu_’ would be a better option.

    ~ Teli

  13. Well, as simple as this process is, I managed to screw this up. =)

    A word of warning from a fella that needed it; backup your database before you fool around with it. Luckily, my host had a back-up of the database before I destroyed it.

    But please don’t allow let my experience with this process deter you from trying it; it truly is an easy thing to do. I’m just an idiot, apparently.

  14. Hi there,

    Thanks for the share. This was something that I’ve always wanted to know.

    Cheers,
    Eddie Gear

  15. There is now a WordPress plugin called WP Hive (http://wp-hive.com/) that let’s you run multiple websites off a single database and a single instance of WordPress. I’ve been running it for several months, and have upgraded from 2.6 to 2.7 without issue. The best part is there is not code “hackery”. Use it like any other plugin.

  16. Brian Richmond March 4, 2009 at 2:01 pm

    I came here looking for information on how to run multiple instances of WordPress for the same website. In other words, I have multiple web servers hosting the blog with a single database on the back end. Because of the tie to the OS for media file storage, it’s a crap shoot as to whether your visitor will be able to view or download a file or not. I posted a blog entry at

    http://blog.4minds.com/2009/02/24/wordpress-in-the-enterprise/

    which explains better what I’m trying to accomplish. If you have any useful feedback that would help me out with this issue, please let me know, or comment on my entry.

  17. Hi,
    Great tips! I usually use many dbs for local testing. Now, it’s better!
    Thanks.

  18. Thanks for the info… It took me less than 30 secs. to answer this question (including the time it took to search google). I greatly appreciate the help! ;-)

    Peace.

  19. Great Job! This is just the tutorial I am looking for.

  20. Hi…

    i don’t know if i should be writing here or not… but i need your help.
    well it goes like this i used blogger from 2005-2006 then just about the time i was beginning to earn something they disabled my account for no apparent reason. then i stopped blogging. but now i want back in. and i want to use wordpress this time..

    turns out i don’t know anything about it so i need your professional advice.. I want to create a Multiple author site since my friends would be blogging along with me too.. I want to build a site with four blogs in it,. It should have like five links in the top… one would be home that would have all the blog posts. one would say ‘computer and internet’ which would open a blog exclusively made for post only for computer and internet.. and there should be more blogs like one for the ‘voice of youth’..

    so i want a site in which there are four blogs and a forum… and i need to know whether i would be able to do it with wordpress and if yes are there any tutorials out there,

    and should i buy a host before making the site… or should i use some free host first to build the site and then move it too a professional hosting platform..

    Thanks

  21. It is awesome with this prefix. I have 11 different WordPress sites running in same db – everything is running smoothly – GREAT!

  22. cool this was quick then expected…..you saved me from installing WPMU

  23. Hello,

    Thanks for posting but I have been playing around with the code to get all of the wordpresses (5) to work with a single login.
    I can’t get in to details because each version is different, but basically in order to create multiple wordpresses, you have to create a MAIN wordpress and rewrite most of the code where the passwords, login sessions, etc points to the “MAIN” user information. It can be a nightmare.

    I’m doing this because I am making multiple languages. I know this is kinda retarded and redundunt, but my boss insists on it because he wants PROPPER and Exact Translations.

  24. i been thinking of installing another wordpress on different URL for different languages. May i know if sharing the same database with another new wordpress would be affected the content of the post? Because i need to shown different languages. What about the subscriber user database? Are there sharing the same or i need to add in in the new wordpress? Thanks

  25. Hi, if i’m use 1 single database file, does anyone know how/what to do if i want my WP blogs display same post content at all?

    Let say I update my main blog, all my other blogs will display same content.

  26. Hi – just stumbled across this post and you seem to be answering lots of questions so…

    1. I would like to use wordpress as the cms for a group of sites, one cms, one database, four websites. I don’t really need the layout so much, just the ability to use the content management system for entry. Is this possible?

    2. Some stuff would be unique to each site, but most would be relevant to more than one if not all – example would be three companies in the same group sharing news. Is this possible?

    3. Lastly can you recommend a book, resource etc to learn wordpress as a cms and things like theme design etc.?

    Thank you

    Daniel

  27. Globalvariable June 12, 2010 at 8:41 pm

    Hi,
    If I have a common database, does it mean if my users register in any one of my sites, they would be able to use the same login credentials at all my sites?

    Is the above tutorial enough to achieve this?

    Thanks

  28. Hi Teli,
    I have three (or possibly 4) sites running on the same database and don’t have any problems with the sites, but I do have problems logging in to the admin pages. Every time I go to log in, I have to reset the passwords – wordpress doesn’t seem to remember what my passwords are – is this something you have come across, and if so is there a solution that I am missing.

    Thanks in advance for your help.
    Rob

  29. Just reposting in order to get email notifications..

    Ta.

  30. Oh this is amazing!
    I searched the web abouth a month ago for a tutorial on this, without any luck – but thanks to your extremely simple guide I’ve made it work.

    Thank you!

  31. Not sure if this runs along the same vein but what I’m trying to do is have 1 installation of WP but allow the viewer to select which theme / style they want to view it in.

    So the content and site would be the same, just that they would be able to see it presented differently.

    Any help?

  32. @Rob: Make sure that you place a checkmark in the “Remember me” box next to the login button and WP should remember you for a couple of weeks before forcing you to log in again. (This needs to be done for each of your blogs.) If you have checked the “Remember me” box and you are still being booted out, there may be a problem with your browser’s acceptance of cookies.

    @OrrivieV: You need to search for a WordPress style or theme switcher. I don’t know any links off the top of my head, but I know there are a couple available. A Google search should yield some good results, or you can simply search the WP plugin repository for “theme switcher” or “style switcher” and see what pops up.