Access violation with Drupal 7 multisite using shared DB 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' =&gt; 
  array (
    'default' =&gt; 
    array (
      'database' =&gt; 'oxone',
      'username' =&gt; 'oxone',
      'password' =&gt; '*********',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; array(
         'default'   =&gt; 'oxone.',
         'users'     =&gt; 'oxshared.',
         'users_roles'     =&gt; 'oxshared.',
         'sessions'  =&gt; 'oxshared.',
         'role'      =&gt; 'oxshared.',
         'role_permission'      =&gt; 'oxshared.',
         'authmap'   =&gt; 'oxshared.',
     ),
    ),
  ),
  'oxshared' =&gt; 
  array (
    'default' =&gt; 
    array (
      'database' =&gt; 'oxshared',
      'username' =&gt; 'oxshared',
      'password' =&gt; '**********',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; '',
    ),
  ), 
);


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.
The question is closed. It seams to be that to have some tables in a separate database:
1) that second db should be placed at the same host as default one.
2) the user who has access to the default db should also has access to the second db.

Adding one more db to settings.php is not needed. It my case the correct settings.php db config has to look like:

$databases = array (
  'default' =&gt; 
  array (
    'default' =&gt; 
    array (
      'database' =&gt; 'oxone',
      'username' =&gt; 'oxone',
      'password' =&gt; '*********',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; array(
         'default'   =&gt; 'oxone.',
         'users'     =&gt; 'oxshared.',
         'users_roles'     =&gt; 'oxshared.',
         'sessions'  =&gt; 'oxshared.',
         'role'      =&gt; 'oxshared.',
         'role_permission'      =&gt; 'oxshared.',
         'authmap'   =&gt; 'oxshared.',
     ),
    ),
  ),
);