Two Sites, One Database, One Installation of Drupal: DB Setup

The guidance provided below assumes:

  • You have read "Multiple Sites, Multiple Databases, One Installation of Drupal" located on this site.
  • You are working with Drupal 4.6.x.
  • You are only sharing two sites.
  • The primary site is already configured.
  • You have a second domain directed to your Drupal home directory.

The processes that differ are the database setup and the settings.php configuration. This article focuses on the database setup. There are two parts to this process: create new tables and edit tables.
Step 1: Create new database tables
This process assumes that you are using all the same database tables as the primary site except four: blocks, boxes, menu, and cache. The primary web site will use these original four tables. The secondary web site will have its own version of each. The names need to be changed. Drupal uses a table prefix function such that the four tables will have a prefix added to each. For example, secondsite_blocks, secondsite_boxes, secondsite_menu, and secondsite_cache.
To create additional tables in your Drupal database, you need to be able to access your database and create tables. If you performed your own install of Drupal for the primary site, you have access to a tool such as phpMyAdmin. Or, you have installed the dba.module, you can use that interface. Choose an interface and access the SQL/Query interface and get ready to copy the applicable SQL code from the database.mysql file.
Because there are different versions of Drupal, it is suggested that you use the create table SQL provided in the database.mysql file provided with Drupal. Open database.mysql in Notepad and locate the SQL for each table. Copy the SQL into the SQL/Query interface. Before you continue, edit the table name. If the table is the blocks table, change the name to secondsitename_blocks. Then execute the query. You can create all four tables at once or one at a time, always remembering to add the exact same prefix to the table name.
Step 2: Edit tables
Once you have the four new empty tables in place, you need to edit two tables.
First, you need to give the blocks table the default records. The easy way to do this is to export the default records that were created when you configured the primary site. Again, you can use whatever tool you want. The objective is to locate and copy the SQL that inserts a record. It will look like this.
INSERT INTO blocks VALUES("article","0","0","0","0","0","0","0","","");
There will be several of them. Copy them all and paste them into the SQL/Query interface. Before you execute the query, change the table name from blocks to secondsitename_blocks (to match the table name you use when creating the table). Execute the query. This will kick start your second site blocks and allow you to edit them and make them different than the ones in your primary site.
Second, you need to clear the cache table in the primary site. You need to use the empty command and can do this from your choice of database interfaces.