Posted by r2b2 on February 9, 2011 at 6:56am
Site1.com and Site2.com resides on the same server but each have their own databases. If I wanted to share the users table between these two sites for single sign on capability , can I just create a MySQL View of Site1.com's users table and store it Site2.com's users table ? I managed to create an update-able (non-drupal db, just for testing) View using :
create view users as select * from database1.users;
I haven't tried this yet in Drupal and I dont know what the implications will be. Is this possible?
Thanks!
Categories: multisite
Comments
Sharing tables
The way I share my tables is with this code in each settings.php file.
$db_prefix = array(
'default' => '',
'users' => 'host_shared.',
'sessions' => 'host_shared.',
'users_roles' => 'host_shared.',
'role' => 'host_shared.',
'profile_fields' => 'host_shared.',
'profile_values' => 'host_shared.',
'authmap' => 'host_shared.'
);
I created a separate shared table, and each settings.php file points to it. I also deleted these tables from each of the databases.
D7 or D6?
In D7, sharing of tables is described in the default.settings.php file. It is basically what joyseeker describes above. Be sure to drop the shared tables from each of the individual site's database.
Unfortunately we can't use
Unfortunately we can't use Drupal 7 for production yet. I did tried this yesterday ,dropping users and users_roles and creating view based on the tables from the other database and its worked. Although I would still investigate how to do this on D6.
I think my ultimate goal really is to have 1 admin interface for all sites, with users and user roles (and other user-related tables) shared across sites.