How to use separate databases for Drupal tables?
In the settings.php file used for the site, you can specific a different prefix for each database table.

  $databases['default']['default'] = array(
    'driver' =&gt; 'mysql',
    'database' =&gt; 'databasename',
    'username' =&gt; 'username',
    'password' =&gt; 'password',
    'host' =&gt; 'localhost',
    'prefix' =&gt; array(
      'default'   =&gt; 'main_',
      'users'     =&gt; 'shared_',
      'sessions'  =&gt; 'shared_',
      'role'      =&gt; 'shared_',
      'authmap'   =&gt; 'shared_',
    ),
    'collation' =&gt; 'utf8_general_ci',
  );


You can also refer different databases, or schema, using code similar to the following one.

  $databases['default']['default'] = array(
    'driver' =&gt; 'mysql',
    'database' =&gt; 'databasename',
    'username' =&gt; 'username',
    'password' =&gt; 'password',
    'host' =&gt; 'localhost',
    'prefix' =&gt; array(
      'default'   =&gt; 'main.',
      'users'     =&gt; 'shared.',
      'sessions'  =&gt; 'shared.',
      'role'      =&gt; 'shared.',
      'authmap'   =&gt; 'shared.',
    ),
    'collation' =&gt; 'utf8_general_ci',
  );


The difference between the last snippet, and the previous one is that the last character used for the prefixes is the dot, not the underscore. That causes the database engine to select a different database/schema, instead of the currently set one.
To be clearer, in the code I shown the database engine is still MySQL running on localhost; what changes is that for the users table, Drupal will use the shared database instead of the databasename one.

As far as I know, this is valid for Drupal 7, or higher. The same trick is not reported in the comments present in the default.settings.php file that comes with Drupal 6.

Reference

The comments shown in the default.settings.php file.