I'm building a Drupal 7 multisite and I want to have a separate database for each site but with some shared tables. So, I have two sites called siteone and sitetwo. I also have 3 databases - oxone (for first site), oxtwo (for second one) and oxshared (where I want to keep shared tables for both sites.
I used the following config for settings.php (for siteone), but it shows me a PDO exception... What I'm doing wrong? Will be very appreciate for any help or advice.
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'oxone',
'username' => 'oxone',
'password' => '*********',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => array(
'default' => 'oxone.',
'users' => 'oxshared.',
'users_roles' => 'oxshared.',
'sessions' => 'oxshared.',
'role' => 'oxshared.',
'role_permission' => 'oxshared.',
'authmap' => 'oxshared.',
),
),
),
'oxshared' =>
array (
'default' =>
array (
'database' => 'oxshared',
'username' => 'oxshared',
'password' => '**********',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
The exception is:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'oxone'@'localhost' for table 'users': SELECT u., s. FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid; Array ( [:sid] => _5UERN3eEWligNxBusEYCq3Lnf48pfvWDu9FDQDZUI8 ) in _drupal_session_read() (line 102 of /home/qsoul/public_html/siteone.dev.lo/includes/session.inc)
Why doesn't Drupal use the oxshared user when accessing the tables in the oxshared database, as defined in the prefix
array? It uses the oxone user instead.
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'oxon'@'localhost' for table 'users': SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid; Array ( [:sid] => _5UERN3eEWligNxBusEYCq3Lnf48pfvWDu9FDQDZUI8 ) in _drupal_session_read() (line 102 of /home/qsoul/public_html/siteone.dev.lo/includes/session.inc).
oxon
voxone
)oxshared
user to get those shared data, but tryes to do it viaoxeone
? p.s. 'oxon' typo is only here (just made a type while replacing real data), in setings.php its 'oxone'.