function drush_valid_db_credentials

8.0.x drush_valid_db_credentials()
6.x drush_valid_db_credentials()
7.x drush_valid_db_credentials()
3.x drush_valid_db_credentials()
4.x drush_valid_db_credentials()
5.x drush_valid_db_credentials()
master drush_valid_db_credentials()

Tests the currently loaded database credentials to ensure a database connection can be made.


bool $log_errors: (optional) If TRUE, log error conditions; otherwise be quiet.

Return value

bool TRUE if database credentials are valid.

1 call to drush_valid_db_credentials()


includes/, line 381
Functions used by drush to query the environment and setting the current configuration.


function drush_valid_db_credentials() {
  try {
    $sql = drush_sql_get_class();
    if (!$sqlVersion = drush_sql_get_version()) {
      drush_log(dt('While checking DB credentials, could not instantiate SQLVersion class.'), 'debug');
      return FALSE;
    if (!$sqlVersion->valid_credentials($sql->db_spec())) {
      drush_log(dt('DB credentials are invalid.'), 'debug');
      return FALSE;
    return $sql->query('SELECT 1;');
  catch (Exception $e) {
    drush_log(dt('Checking DB credentials yielded error: @e', array('@e' => $e->getMessage())), 'debug');
    return FALSE;