diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 906c5cc..3e3853a 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -3166,6 +3166,7 @@ function drupal_classloader($class_loader = NULL) {
     $loader->registerNamespaces(array(
       'Drupal\Core' => DRUPAL_ROOT . '/core/lib',
       'Drupal\Component' => DRUPAL_ROOT . '/core/lib',
+      'Drupal\Driver' => DRUPAL_ROOT . '/drivers/lib',
     ));
 
     // Register namespaces and PEAR-like prefixes for vendor libraries managed
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 803947f..6bbc5ff 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1026,6 +1026,11 @@ function install_settings_form($form, &$form_state, &$install_state) {
 function install_settings_form_validate($form, &$form_state) {
   $driver = $form_state['values']['driver'];
   $database = $form_state['values'][$driver];
+  $drivers = drupal_get_database_types();
+  $reflection = new \ReflectionClass($drivers[$driver]);
+  $install_namespace = $reflection->getNamespaceName();
+  // Cut the trailing \Install from namespace.
+  $database['namespace'] = substr($install_namespace, 0, strrpos($install_namespace, '\\'));
   $database['driver'] = $driver;
 
   // TODO: remove when PIFR will be updated to use 'db_prefix' instead of
diff --git a/core/includes/install.inc b/core/includes/install.inc
index e9d666f..d33bb0a 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -134,12 +134,18 @@ function drupal_get_database_types() {
   // contains a database.inc file. That allows us to drop in additional drivers
   // without modifying the installer.
   require_once DRUPAL_ROOT . '/core/includes/database.inc';
-  foreach (file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) {
+  // Allow any valid PHP identifier.
+  // @see http://www.php.net/manual/en/language.variables.basics.php.
+  $mask = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/';
+  $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, array('recurse' => FALSE));
+  if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) {
+    $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, array('recurse' => FALSE));
+  }
+  foreach ($files as $file) {
     if (file_exists($file->uri . '/Install/Tasks.php')) {
       $drivers[$file->filename] = $file->uri;
     }
   }
-
   foreach ($drivers as $driver => $file) {
     $installer = db_installer_object($driver);
     if ($installer->installable()) {
@@ -954,5 +960,11 @@ function db_installer_object($driver) {
   // We cannot use Database::getConnection->getDriverClass() here, because
   // the connection object is not yet functional.
   $task_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Install\\Tasks";
-  return new $task_class();
+  if (class_exists($task_class)) {
+    return new $task_class();
+  }
+  else {
+    $task_class = "Drupal\\Driver\\Database\\{$driver}\\Install\\Tasks";
+    return new $task_class();
+  }
 }
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 51efaf4..5b16086 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -620,7 +620,13 @@ protected function expandArguments(&$query, &$args) {
   public function getDriverClass($class) {
     if (empty($this->driverClasses[$class])) {
       $driver = $this->driver();
-      $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\{$class}";
+      if (!empty($this->connectionOptions['namespace'])) {
+        $driver_class  = $this->connectionOptions['namespace'] . '\\' . $class;
+      }
+      else {
+        // Fallback for Drupal 7 settings.php.
+        $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\{$class}";
+      }
       $this->driverClasses[$class] = class_exists($driver_class) ? $driver_class : $class;
     }
     return $this->driverClasses[$class];
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 25fe8fa..a54c9cb 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -374,7 +374,13 @@ public static function addConnectionInfo($key, $target, $info) {
       throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
     }
 
-    $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Connection";
+    if (!empty(self::$databaseInfo[$key][$target]['namespace'])) {
+      $driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connection';
+    }
+    else {
+      // Fallback for Drupal 7 settings.php.
+      $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Connection";
+    }
     $new_connection = new $driver_class(self::$databaseInfo[$key][$target]);
     $new_connection->setTarget($target);
     $new_connection->setKey($key);
