Is there any way to list all possible database connections using Drush? I am debugging an application where db connections are not written in settings.php and I'm not able to find all possible connections. And in code I can see

$database = db_set_active('test');

Is there any way to list the db connection names like test, test1, test2? Any help is appreciated.

2 Answers 2


All database connection strings are in global $databases variable;

global $databases;

with drush:

drush php-eval 'global $databases; print_r($databases);' 

I don't know if Drush is able to do it, but in Drupal 6 you might try to look for the global variable $db_url in your code using grep or similar:

The "Set up multiple databases on the fly" section on the documentation below explains how the connections are set, for both Drupal 7 and Drupal 6 and older:


For instance, for Drupal 6 you might find the following to define an alternative 'mydb' connection:

//set up the new database value
$db_url['mydb'] = 'mysql://user:pwd@localhost/anotherdb';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.