Share a single database across multiple sites

Drupal 6 and later supports sharing a database with other web applications with the table prefix, also known as $db_prefix from settings.php.

The table prefix is defined in your Drupal site's settings.php file, and when it is present Drupal will place the prefix before each table name in the database. So if the table prefix were 'mysite_' then Drupal would look for tables named 'mysite_access', 'mysite_actions', and so on (instead of the default tables names 'access', 'actions', etc.) This allows more than one Drupal site, or even Drupal and other products, to share the same database, because the table names will not collide with one another. You can have another Drupal instance with table prefix 'mysite2_' sharing the database with 'mysite_' and indeed many other instances as long as each one has a unique table prefix.

If your hosting company only provides you with one database, then sharing it between multiple Drupal sites with table prefixes can be a cost effective alternative to paying for extra databases!

Site Building Guide

This is the customization guide and 'how to' guide for implementing business functionality and features into your Drupal site.

Pages

Subscribe with RSS Subscribe to RSS - Site administrators