Multiple WordPress Blogs, One Database

by Kevin on April 22, 2009

This isn’t a new tutorial, but one that I made use of recently, as it becomes difficult to manage multiple databases for a single site, especially when you are using sub-domains and folders as extended areas of your site, rather than creating an entirely new area to your site. I’ll get into some more reasons why you would want to make use of this ability later on, but for now, I’ll start with how you achieve this.

Please be aware that I am not responsible for any damages that are caused as a result of changes you make to your blog, This tutorial is simple to carry out, but could be quite difficult, if not impossible to fix if you don’t have good backups and don’t know how to edit the PHP code or file structure of your blogs/server files.

6 Easy Steps

  1. Use an FTP or folder client to view your currently installed blog. Note: If you don’t already have a blog set up, now would be a good time to do the simple setup for anew WordPress blog (creating a new database).
  2. Create an additional folder or subdomain (you may need to configure this to work properly), naming it something like blog, as it will appear as http://example.com/blog/.
  3. Find the wp-config.php file located in the location where your primary blog is hosted.
  4. Copy this file over to the folder, along with an extracted, fresh installation of WordPress (from WordPress.org).
  5. Find the line: $table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'  of the copied over configuration file, and change the initial 'wp_' to 'blog_' as is the example above, or any other name.
  6. Go to the site with an Internet browser and go through the traditional installation steps.

These tips will change the default, automatically created, new database to a line in your current table, based on the change you’ve made to the file.

Reasons for Installing Multiple Blogs on One Database

I didn’t really think about having to do this, as my host allows 100 MySQL Databases, but unlimited domains. It really didn’t make sense creating additional databases for folders on websites that I wasn’t planning on expanding too much. Databases that grow too large could cause problems, but many hosts can handle databases that are moderate in size, as they are mostly text – the more posts, the larger the file. Images aren’t really stored in here, but do add some size to it.

The best scenario for needing this ability is if your host has a one main domain/one database limitation. While many have larger limitations, this can really limit the potential of your site, especially if you want separate areas to your site.

For example, you could separate your work and personal blogs (even though this might not be the best example), nearly anything is possible without using additional resources on your server.

Not everyone will want to go through these steps, especially those who are thinking about starting completely separate projects. You wouldn’t want to share multiple sites on the same database or sites that have no relation to one another. You will have a harder time backing up and restoring databases if you would choose to do this.

Conclusion

Getting to know the abilities of databases and some basics on using them, you will be able to extend the power of a single site. There are so many reasons for wanting to use this ability, but it isn’t taken advantage of as often as it should. As in my case, it became useful for separating content from the main page while not having to create a new database.

More details can be found on the WordPress Codex.

9 comments

thanks for this article.
It will really help me with my directory websites
Sarah

by mySql credit databases on November 17, 2009 at 10:16 am. Reply #

thanks for this article.
It will really help me with my directory websites
Sarah

by mySql credit databases on November 17, 2009 at 5:16 am. Reply #

Hi Kevin,

Why didn’t you go with WordPress MU?

I’m converting a site that has many files in multiple sub directories and I don’t want to 301 them all. It looks like the way to go is your route or WordPress MU and have a separate blog for each sub directory of files (keeping the link love, etc).

Thanks,

Jim

by Jim on November 26, 2009 at 11:00 pm. Reply #

The main reason I didn’t use it for this site is due to compatibility with plugins/themes. It would certainly work for any site that is much larger or one that supports users.

Perhaps there is a way from the back-end to specify how WordPress handles the posts, so you don’t have to do the whole redirection?

by Kevin on November 28, 2009 at 8:30 am. Reply #

Hi Kevin,

Why didn’t you go with WordPress MU?

I’m converting a site that has many files in multiple sub directories and I don’t want to 301 them all. It looks like the way to go is your route or WordPress MU and have a separate blog for each sub directory of files (keeping the link love, etc).

Thanks,

Jim

by Jim on November 26, 2009 at 6:00 pm. Reply #

The main reason I didn’t use it for this site is due to compatibility with plugins/themes. It would certainly work for any site that is much larger or one that supports users.

Perhaps there is a way from the back-end to specify how WordPress handles the posts, so you don’t have to do the whole redirection?

by Kevin on November 28, 2009 at 3:30 am. Reply #

Thanks for the response Kevin!

This was exactly what I had feared in deciding between multiple blogs with one database (one site, one db, many WP installations) or wordpress MU – There are a ton of plugins and I guess I would need to test them all out first before making the final decision.

by Jim on November 28, 2009 at 10:41 pm. Reply #

Thanks for the response Kevin!

This was exactly what I had feared in deciding between multiple blogs with one database (one site, one db, many WP installations) or wordpress MU – There are a ton of plugins and I guess I would need to test them all out first before making the final decision.

by Jim on November 28, 2009 at 5:41 pm. Reply #

So nice of you ,it really works ,thanks a lot
thanks a lot , you have solved my big prollem as my host gives me only one worpress blog

by Sajjad on February 23, 2011 at 2:04 am. Reply #

Leave your comment

Required.

Required. Not published.

If you have one.