Running multiple WordPress installations using the same MySQL Database
Did you know that you can host multiple WordPress installations on the same MySQL database? If no, then this article is for you.
There can be many benefits of hosting multiple WordPress installations on the same MySQL database. Usually hosting providers have a limit of how many databases you are allowed to create with their service. Or, it may become too cumbersome to maintain multiple databases. Or, you may want to group together related blogs under the same physical database. Regardless of what your requirement is, it takes very little to host multiple installations on one database.
All it takes is a small change to the wp-config.php file for your blog. Take a look at the screen shot of a wp-config.php file:
Notice the highlighted area. By default the value of $table_prefix is ‘wp_’.
You can set this value to anything you want. The trick is to do this before you install WordPress. If you set the prefix to something which is specific to the blog that you are installing, then WordPress will automatically create the tables for that blog with the proper prefixes.
This allows you to install as many blogs as you want on the same database. So, if you wanted to install another blog on this database, you would simply give another prefix to the second blog.
I use this method all the time. Because when I do this, I don’t need to backup each blog individually. I simply backup one single database and all my blogs get backed up.
Note, this shouldn’t be confused with WordPress MU, which is totally different beast all together. This is for installing WordPress single user, but multiple instances of it.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

April 15th, 2008 at 9:09 pm
Interesting that you wrote about this… If you want multi-user blogging and multi-blog support I suggest checking out Lyceum. This is a shameless plug because I was involved in the initial development & design when I was a Research Assistant at ibiblio / UNC. Lyceum is based on Wordpress and scales better than Wordpress MU.
Thats just my $0.02 / INR 2
April 15th, 2008 at 11:21 pm
@Sayan, I have taken a look at Lyceum before when I was evaluating options for use at work. I didn’t know you had worked on it, else I would have asked you
April 16th, 2008 at 1:08 am
Now you know
I would be glad to put you in touch with my friend John ‘JJB’ Bachir who is the lead developer of Lyceum.
April 16th, 2008 at 1:18 am
Sayan… next time I go hunting for a CMS, I am getting in touch with you.
May 13th, 2008 at 4:23 pm
hi,
/ You can set this value to anything you want. The trick is to do this before you install WordPress. /
Ok, but how to change before instalation if I have no this file wp-config.php
can you please tell me with few steps how to do it
Thanks
May 13th, 2008 at 5:35 pm
@kolio - you have to have a wp-config.php file, if you have freshly downloaded the wordpress installer, then this file is called wp-config-sample.php and you need to rename it to wp-config.php.
Refer to the installation steps defined on wordpress.org.
June 13th, 2008 at 5:11 am
[...] Running multiple WordPress installations using the same MySQL Database Easy and awesome for those with db limits [...]
June 20th, 2008 at 6:53 am
I have a wordpress 2.5.1 site with an existing
database of articles. When I set up additional sites
to use the existing DB of articles, will I need to
use the same ‘DB_NAME’, ‘DB_USER’ and ‘DB_PASSWORD’
in each wp-config.php file?
When I give each new site a different table prefix,
will I also have to give the original site a prefix?
Will this make me loose my original DB?
Will I have to start with all new blogs before I
add any articles to get them to all work with the
same DB?
I’m new to all this and would appreciate any help.
Thanks, pappy
June 20th, 2008 at 8:56 am
Hi Pappy,
Use the same db_name, db_user, db_password, etc… the only thing you should change for the new blog is the prefix.
The original site should stay the same (you don’t need to change anything in that).
Let me know if you need more help on this.
Cheers.
June 20th, 2008 at 5:50 pm
Thanks for your reply.
Will the existing categories and articles on the old site automatically be displayed on the new sites or will I have to create the categories manually?
Will any new articles posted to one site automatically show up on all my sites using the same DB?
Thanks,
pappy
June 20th, 2008 at 6:13 pm
@Pappy… nopes, they will be totally two different blogs (as if you had used two different databases)…
June 20th, 2008 at 7:12 pm
How can I get the same info to show up on 2 different websites?
Thanks
Pappy
June 21st, 2008 at 2:12 am
There is no direct and easy way… sorry…
July 5th, 2008 at 4:20 am
@Pappy: You have to do a “Domain Redirect”. Google the term, you would get loads of info.
Happy blogging.
July 5th, 2008 at 4:24 am
By the way, you can use this for all kinds of sites.
July 20th, 2008 at 12:02 pm
[...] Running multiple WordPress installations using the same MySQL Database [...]
July 24th, 2008 at 1:42 am
Thanks, man, this simple post saved me time googling!