diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 77458a1..46ccd62 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -720,13 +720,14 @@ function drupal_settings_initialize() {
   global $base_url, $base_path, $base_root, $script_path;
 
   // Export these settings.php variables to the global namespace.
-  global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url, $config_directories;
+  global $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url, $config_directories;
   $conf = array();
 
   // Make conf_path() available as local variable in settings.php.
   $conf_path = conf_path();
   if (is_readable(DRUPAL_ROOT . '/' . $conf_path . '/settings.php')) {
     include_once DRUPAL_ROOT . '/' . $conf_path . '/settings.php';
+    drupal_container()->setParameter('database.info', isset($databases) ? $databases : array());
   }
   $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
 
@@ -2129,14 +2130,14 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) {
           _drupal_bootstrap_configuration();
           break;
 
-        case DRUPAL_BOOTSTRAP_PAGE_CACHE:
-          _drupal_bootstrap_page_cache();
-          break;
-
         case DRUPAL_BOOTSTRAP_DATABASE:
           _drupal_bootstrap_database();
           break;
 
+        case DRUPAL_BOOTSTRAP_PAGE_CACHE:
+          _drupal_bootstrap_page_cache();
+          break;
+
         case DRUPAL_BOOTSTRAP_VARIABLES:
           _drupal_bootstrap_variables();
           break;
@@ -2238,15 +2239,14 @@ function _drupal_bootstrap_configuration() {
   drupal_environment_initialize();
   // Start a page timer:
   timer_start('page');
+  // Activate the class loader.
+  drupal_classloader();
   // Initialize the configuration, including variables from settings.php.
   drupal_settings_initialize();
 
   // Make sure we are using the test database prefix in child Drupal sites.
   _drupal_initialize_db_test_prefix();
 
-  // Activate the class loader.
-  drupal_classloader();
-
   // Load the procedural configuration system helper functions.
   require_once DRUPAL_ROOT . '/core/includes/config.inc';
 }
@@ -2320,7 +2320,7 @@ function _drupal_initialize_db_test_prefix() {
     $test_info['test_run_id'] = $test_prefix;
     $test_info['in_child_site'] = TRUE;
 
-    foreach ($GLOBALS['databases']['default'] as &$value) {
+    foreach ($databases['default'] as &$value) {
       // Extract the current default database prefix.
       if (!isset($value['prefix'])) {
         $current_prefix = '';
@@ -2337,6 +2337,7 @@ function _drupal_initialize_db_test_prefix() {
         'default' => $current_prefix . $test_prefix,
       );
     }
+    $container->setParameter('database.info', $databases);
   }
 }
 
@@ -2347,12 +2348,14 @@ function _drupal_bootstrap_database() {
   // Redirect the user to the installation script if Drupal has not been
   // installed yet (i.e., if no $databases array has been defined in the
   // settings.php file) and we are not already installing.
-  if (empty($GLOBALS['databases']) && !drupal_installation_attempted()) {
+  $container = drupal_container();
+  $databases = $container->getParameter('database.info');
+
+  if (!$databases && !drupal_installation_attempted()) {
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     install_goto('core/install.php');
   }
 
-
   // Initialize the database system. Note that the connection
   // won't be initialized until it is actually requested.
   require_once DRUPAL_ROOT . '/core/includes/database.inc';
@@ -2437,11 +2440,25 @@ function drupal_container(Container $new_container = NULL, $rebuild = FALSE) {
     $container
       ->register('config.cachedstorage.storage', 'Drupal\Core\Config\FileStorage')
       ->addArgument(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
-    // @todo Replace this with a cache.factory service plus 'config' argument.
-    $container
-      ->register('cache.config')
-      ->setFactoryClass('Drupal\Core\Cache\CacheFactory')
-      ->setFactoryMethod('get')
+
+    // This will be overridden by settings.php in drupal_settings_initialize().
+    $container->setParameter('database.info', array());
+    $container->register('database', 'Drupal\Core\Database\Connection')
+      ->setFactoryClass('Drupal\Core\Database\Database')
+      ->setFactoryMethod('getConnection')
+      ->addArgument('default')
+      ->addArgument(NULL)
+      ->addArgument('%database.info%');
+    $container->register('database.slave', 'Drupal\Core\Database\Connection')
+      ->setFactoryClass('Drupal\Core\Database\Database')
+      ->setFactoryMethod('getConnection')
+      ->addArgument('slave')
+      ->addArgument(NULL)
+      ->addArgument('%database.info%');
+    $container->register('cache', 'Drupal\Core\Cache\DatabaseBackend')
+      ->addArgument(new Reference('database'));
+    $container->register('cache.config', 'Drupal\Core\Cache\DatabaseBackend')
+      ->addArgument(new Reference('database'))
       ->addArgument('config');
 
     $container
diff --git a/core/includes/cache.inc b/core/includes/cache.inc
index 341d77f..ab6cc36 100644
--- a/core/includes/cache.inc
+++ b/core/includes/cache.inc
@@ -26,21 +26,13 @@
  * @see Drupal\Core\Cache\CacheBackendInterface
  */
 function cache($bin = 'cache') {
-  // Use the advanced drupal_static() pattern, since this is called very often.
-  static $drupal_static_fast;
-  if (!isset($drupal_static_fast)) {
-    $drupal_static_fast['cache'] = &drupal_static(__FUNCTION__, array());
-  }
-  $cache_objects = &$drupal_static_fast['cache'];
-
   // Temporary backwards compatibiltiy layer, allow old style prefixed cache
   // bin names to be passed as arguments.
   $bin = str_replace('cache_', '', $bin);
 
-  if (!isset($cache_objects[$bin])) {
-    $cache_objects[$bin] = CacheFactory::get($bin);
-  }
-  return $cache_objects[$bin];
+  $container = drupal_container();
+  $service = $container->has("cache.$bin") ? "cache.$bin" : 'cache';
+  return $container->get($service)->bin($bin);
 }
 
 /**
@@ -57,7 +49,12 @@ function cache($bin = 'cache') {
  *   The list of tags to invalidate cache items for.
  */
 function cache_invalidate(array $tags) {
-  foreach (CacheFactory::getBackends() as $bin => $class) {
-    cache($bin)->invalidateTags($tags);
+  $container = drupal_container();
+  $cache_services = array_filter($container->getServiceIds(), function ($value) { return substr($value, 0, 6) == 'cache.';});
+  $cache_services[] = 'cache';
+  $backends = array();
+  foreach ($cache_services as $service) {
+    $backends[$service] = get_class($container->get($service));
   }
+  return $backends;
 }
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index dfb41f5..1ca52d2 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -9,6 +9,7 @@
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\DependencyInjection\Reference;
 
 /**
  * @file
@@ -349,7 +350,8 @@ function install_begin_request(&$install_state) {
   // because any data put in the cache during the installer is inherently
   // suspect, due to the fact that Drupal is not fully set up yet.
   require_once DRUPAL_ROOT . '/core/includes/cache.inc';
-  $conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\InstallBackend');
+  $container = drupal_container();
+  $container->register('cache', 'Drupal\Core\Cache\InstallBackend');
 
   // The install process cannot use the database lock backend since the database
   // is not fully up, so we use a null backend implementation during the
@@ -375,6 +377,8 @@ function install_begin_request(&$install_state) {
     // Initialize the database system. Note that the connection
     // won't be initialized until it is actually requested.
     require_once DRUPAL_ROOT . '/core/includes/database.inc';
+    $container->register('cache', 'Drupal\Core\Cache\DatabaseBackend')
+      ->addArgument(new Reference('database'));
 
     // Verify the last completed task in the database, if there is one.
     $task = install_verify_completed_task();
@@ -942,8 +946,8 @@ function install_verify_completed_task() {
  * Verifies that settings.php specifies a valid database connection.
  */
 function install_verify_database_settings() {
-  global $databases;
-  if (!empty($databases)) {
+  $container = drupal_container();
+  if (($databases = $container->getParameter('database.info'))) {
     $database = $databases['default']['default'];
     drupal_static_reset('conf_path');
     $settings_file = './' . conf_path(FALSE) . '/settings.php';
@@ -1040,6 +1044,7 @@ function install_settings_form_validate($form, &$form_state) {
   unset($database['db_prefix']);
 
   $form_state['storage']['database'] = $database;
+  drupal_container()->setParameter('database.info', array('default' => $database));
   $errors = install_database_errors($database, $form_state['values']['settings_file']);
   foreach ($errors as $name => $message) {
     form_set_error($name, $message);
@@ -1050,7 +1055,6 @@ function install_settings_form_validate($form, &$form_state) {
  * Checks a database connection and returns any errors.
  */
 function install_database_errors($database, $settings_file) {
-  global $databases;
   $errors = array();
 
   // Check database type.
@@ -1065,17 +1069,15 @@ function install_database_errors($database, $settings_file) {
 
     // Run tasks associated with the database type. Any errors are caught in the
     // calling function.
-    $databases['default']['default'] = $database;
     // Just changing the global doesn't get the new information processed.
     // We need to close any active connections and tell the Database class to
     // re-parse $databases.
     if (Database::isActiveConnection()) {
       Database::closeConnection();
     }
-    Database::parseConnectionInfo();
 
     try {
-      db_run_tasks($driver);
+      db_run_tasks($driver, $database);
     }
     catch (TaskException $e) {
       // These are generic errors, so we do not have any specific key of the
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 3c30c89..e8223ec 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -169,7 +169,7 @@ function drupal_get_database_types() {
   }
 
   foreach ($drivers as $driver => $file) {
-    $installer = db_installer_object($driver);
+    $installer = db_installer_object($driver, drupal_container()->getParameter('database.info'));
     if ($installer->installable()) {
       $databases[$driver] = $installer;
     }
@@ -947,8 +947,8 @@ function install_profile_info($profile, $langcode = 'en') {
  * TABLE to database specific functions like stored procedures and client
  * encoding.
  */
-function db_run_tasks($driver) {
-  db_installer_object($driver)->runTasks();
+function db_run_tasks($driver, $database) {
+  db_installer_object($driver, $database)->runTasks();
   return TRUE;
 }
 
@@ -958,9 +958,9 @@ function db_run_tasks($driver) {
  * @param $driver
  *   The name of the driver.
  */
-function db_installer_object($driver) {
+function db_installer_object($driver, $database) {
   // 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();
+  return new $task_class($database);
 }
diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
index 02c9dd2..06f03f7 100644
--- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
@@ -55,14 +55,6 @@
   const CACHE_PERMANENT = 0;
 
   /**
-   * Constructs a new cache backend.
-   *
-   * @param $bin
-   *   The cache bin for which the object is created.
-   */
-  function __construct($bin);
-
-  /**
    * Returns data from the persistent cache.
    *
    * Data may be stored as either plain text or as serialized data. cache_get()
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index e62f1da..341410c 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core\Cache;
 
-use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Connection;
 use Exception;
 
 /**
@@ -24,6 +24,11 @@ class DatabaseBackend implements CacheBackendInterface {
   protected $bin;
 
   /**
+   * A database connection object.
+   */
+  protected $dbConnection;
+
+  /**
    * A static cache of all tags checked during the request.
    */
   protected static $tagCache = array();
@@ -31,13 +36,21 @@ class DatabaseBackend implements CacheBackendInterface {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::__construct().
    */
-  function __construct($bin) {
+ function __construct(Connection $connection, $bin = NULL) {
+    $this->dbConnection = $connection;
+    if ($bin) {
+      $this->bin($bin);
+    }
+  }
+
+  function bin($bin) {
     // All cache tables should be prefixed with 'cache_', except for the
     // default 'cache' bin.
     if ($bin != 'cache') {
       $bin = 'cache_' . $bin;
     }
     $this->bin = $bin;
+    return $this;
   }
 
   /**
@@ -61,7 +74,7 @@ function getMultiple(&$cids) {
       // is used here only due to the performance overhead we would incur
       // otherwise. When serving an uncached page, the overhead of using
       // ::select() is a much smaller proportion of the request.
-      $result = Database::getConnection()->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . Database::getConnection()->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
+      $result = $this->dbConnection->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . $this->dbConnection->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => $cids));
       $cache = array();
       foreach ($result as $item) {
         $item = $this->prepareItem($item);
@@ -136,7 +149,7 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra
     }
 
     try {
-      Database::getConnection()->merge($this->bin)
+      $this->dbConnection->merge($this->bin)
         ->key(array('cid' => $cid))
         ->fields($fields)
         ->execute();
@@ -150,7 +163,7 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra
    * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
    */
   function delete($cid) {
-    Database::getConnection()->delete($this->bin)
+    $this->dbConnection->delete($this->bin)
       ->condition('cid', $cid)
       ->execute();
   }
@@ -161,7 +174,7 @@ function delete($cid) {
   function deleteMultiple(array $cids) {
     // Delete in chunks when a large array is passed.
     do {
-      Database::getConnection()->delete($this->bin)
+      $this->dbConnection->delete($this->bin)
         ->condition('cid', array_splice($cids, 0, 1000), 'IN')
         ->execute();
     }
@@ -172,14 +185,14 @@ function deleteMultiple(array $cids) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::flush().
    */
   function flush() {
-    Database::getConnection()->truncate($this->bin)->execute();
+    $this->dbConnection->truncate($this->bin)->execute();
   }
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::expire().
    */
   function expire() {
-    Database::getConnection()->delete($this->bin)
+    $this->dbConnection->delete($this->bin)
       ->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>')
       ->condition('expire', REQUEST_TIME, '<')
       ->execute();
@@ -242,7 +255,7 @@ protected function flattenTags(array $tags) {
   public function invalidateTags(array $tags) {
     foreach ($this->flattenTags($tags) as $tag) {
       unset(self::$tagCache[$tag]);
-      Database::getConnection()->merge('cache_tags')
+      $this->dbConnection->merge('cache_tags')
         ->key(array('tag' => $tag))
         ->fields(array('invalidations' => 1))
         ->expression('invalidations', 'invalidations + 1')
@@ -273,7 +286,7 @@ protected function checksumTags($tags) {
    }
     if ($query_tags) {
       try {
-        if ($db_tags = Database::getConnection()->query('SELECT tag, invalidations FROM {cache_tags} WHERE tag IN (:tags)', array(':tags' => $query_tags))->fetchAllKeyed()) {
+        if ($db_tags = $this->dbConnection->query('SELECT tag, invalidations FROM {cache_tags} WHERE tag IN (:tags)', array(':tags' => $query_tags))->fetchAllKeyed()) {
           self::$tagCache = array_merge(self::$tagCache, $db_tags);
           $checksum += array_sum($db_tags);
         }
@@ -290,7 +303,7 @@ protected function checksumTags($tags) {
    */
   function isEmpty() {
     $this->garbageCollection();
-    $query = Database::getConnection()->select($this->bin);
+    $query = $this->dbConnection->select($this->bin);
     $query->addExpression('1');
     $result = $query->range(0, 1)
       ->execute()
diff --git a/core/lib/Drupal/Core/Cache/InstallBackend.php b/core/lib/Drupal/Core/Cache/InstallBackend.php
index 73aae39..711d6e3 100644
--- a/core/lib/Drupal/Core/Cache/InstallBackend.php
+++ b/core/lib/Drupal/Core/Cache/InstallBackend.php
@@ -7,8 +7,6 @@
 
 namespace Drupal\Core\Cache;
 
-use Exception;
-
 /**
  * Defines a stub cache implementation to be used during installation.
  *
@@ -17,123 +15,66 @@
  * these stub functions can short-circuit the process and sidestep the need for
  * any persistent storage. Obviously, using this cache implementation during
  * normal operations would have a negative impact on performance.
- *
- * If there is a database cache, this backend will attempt to clear it whenever
- * possible. The reason for doing this is that the database cache can accumulate
- * data during installation due to any full bootstraps that may occur at the
- * same time (for example, Ajax requests triggered by the installer). If we
- * didn't try to clear it whenever one of the delete function are called, the
- * data in the cache would become stale; for example, the installer sometimes
- * calls variable_set(), which updates the {variable} table and then clears the
- * cache to make sure that the next page request picks up the new value.
- * Not actually clearing the cache here therefore leads old variables to be
- * loaded on the first page requests after installation, which can cause
- * subtle bugs, some of which would not be fixed unless the site
- * administrator cleared the cache manually.
  */
-class InstallBackend extends DatabaseBackend {
+class InstallBackend implements CacheBackendInterface {
+
+  function bin($bin) {
+    return $this;
+  }
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::get().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::get().
    */
   function get($cid) {
     return FALSE;
   }
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::getMultiple().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
    */
   function getMultiple(&$cids) {
     return array();
   }
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::set().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::set().
    */
   function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::delete().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
    */
-  function delete($cid) {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        parent::delete($cid);
-      }
-    }
-    catch (Exception $e) {}
-  }
+  function delete($cid) {}
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::deleteMultiple().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
    */
-  function deleteMultiple(array $cids) {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        parent::deleteMultiple($cids);
-      }
-    }
-    catch (Exception $e) {}
-  }
+  function deleteMultiple(array $cids) {}
 
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::invalidateTags().
    */
-  function invalidateTags(array $tags) {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        parent::invalidateTags($tags);
-      }
-    }
-    catch (Exception $e) {}
-  }
+  function invalidateTags(array $tags) {}
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::flush().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::flush().
    */
-  function flush() {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        parent::flush();
-      }
-    }
-    catch (Exception $e) {}
-  }
+  function flush() {}
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::expire().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::expire().
    */
-  function expire() {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        parent::expire();
-      }
-    }
-    catch (Exception $e) {}
-  }
+  function expire() {}
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::garbageCollection().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
    */
-  function garbageCollection() {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        parent::garbageCollection();
-      }
-    }
-    catch (Exception $e) {}
-  }
+  function garbageCollection() {}
 
   /**
-   * Overrides Drupal\Core\Cache\DatabaseBackend::isEmpty().
+   * Implements Drupal\Core\Cache\CacheBackendInterface::isEmpty().
    */
   function isEmpty() {
-    try {
-      if (class_exists('Drupal\Core\Database\Database')) {
-        return parent::isEmpty();
-      }
-    }
-    catch (Exception $e) {}
     return TRUE;
   }
 }
diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php
index c1abfe5..5e3bbba 100644
--- a/core/lib/Drupal/Core/CoreBundle.php
+++ b/core/lib/Drupal/Core/CoreBundle.php
@@ -46,14 +46,7 @@ public function build(ContainerBuilder $container) {
     $container->register('language_manager', 'Drupal\Core\Language\LanguageManager')
       ->addArgument(new Reference('request'))
       ->setScope('request');
-    $container->register('database', 'Drupal\Core\Database\Connection')
-      ->setFactoryClass('Drupal\Core\Database\Database')
-      ->setFactoryMethod('getConnection')
-      ->addArgument('default');
-    $container->register('database.slave', 'Drupal\Core\Database\Connection')
-      ->setFactoryClass('Drupal\Core\Database\Database')
-      ->setFactoryMethod('getConnection')
-      ->addArgument('slave');
+
     $container->register('typed_data', 'Drupal\Core\TypedData\TypedDataManager');
 
     $container->register('router.dumper', '\Drupal\Core\Routing\MatcherDumper')
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 6a425de..cd48edf 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Core\Database;
 
+use LogicException;
+
 /**
  * Primary front-controller for the database system.
  *
@@ -144,15 +146,20 @@
   /**
    * Gets the connection object for the specified database key and target.
    *
-   * @param $target
+   * @param string $target
    *   The database target name.
    * @param $key
    *   The database connection key. Defaults to NULL which means the active key.
+   * @param array $database_info
    *
    * @return Drupal\Core\Database\Connection
    *   The corresponding connection object.
    */
-  final public static function getConnection($target = 'default', $key = NULL) {
+  final public static function getConnection($target = 'default', $key = NULL, $database_info = array()) {
+    if (empty(self::$databaseInfo)) {
+      self::parseConnectionInfo($database_info);
+    }
+
     if (!isset($key)) {
       // By default, we want the active connection, set in setActiveConnection.
       $key = self::$activeKey;
@@ -195,7 +202,7 @@
    */
   final public static function setActiveConnection($key = 'default') {
     if (empty(self::$databaseInfo)) {
-      self::parseConnectionInfo();
+      throw new LogicException('Database::setActiveConnection is called without specifying the database information first.');
     }
 
     if (!empty(self::$databaseInfo[$key])) {
@@ -208,10 +215,7 @@
   /**
    * Process the configuration file for database information.
    */
-  final public static function parseConnectionInfo() {
-    global $databases;
-
-    $database_info = is_array($databases) ? $databases : array();
+  final public static function parseConnectionInfo($database_info) {
     foreach ($database_info as $index => $info) {
       foreach ($database_info[$index] as $target => $value) {
         // If there is no "driver" property, then we assume it's an array of
@@ -287,7 +291,7 @@ public static function addConnectionInfo($key, $target, $info) {
    */
   final public static function getConnectionInfo($key = 'default') {
     if (empty(self::$databaseInfo)) {
-      self::parseConnectionInfo();
+      throw new LogicException('Database::getConnectionInfo called without specifying the database information first.');
     }
 
     if (!empty(self::$databaseInfo[$key])) {
@@ -307,7 +311,7 @@ public static function addConnectionInfo($key, $target, $info) {
    */
   final public static function renameConnection($old_key, $new_key) {
     if (empty(self::$databaseInfo)) {
-      self::parseConnectionInfo();
+      throw new LogicException('Database::renameConnection called without specifying the database information first.');
     }
 
     if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
@@ -359,9 +363,9 @@ public static function addConnectionInfo($key, $target, $info) {
    * @throws Drupal\Core\Database\ConnectionNotDefinedException
    * @throws Drupal\Core\Database\DriverNotSpecifiedException
    */
-  final protected static function openConnection($key, $target) {
+  final protected static function openConnection($key, $target, $database_info = array()) {
     if (empty(self::$databaseInfo)) {
-      self::parseConnectionInfo();
+      self::parseConnectionInfo($database_info);
     }
 
     // If the requested database does not exist then it is an unrecoverable
diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php
index 5d34a62..319278f 100644
--- a/core/lib/Drupal/Core/Database/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
@@ -19,6 +19,12 @@
  */
 abstract class Tasks {
 
+  protected $databases = array();
+
+  function __construct($database_info) {
+    $this->databases['default']['default'] = $database_info;
+  }
+
   /**
    * Structure that describes each task to run.
    *
@@ -160,10 +166,7 @@ public function runTasks() {
    */
   protected function connect() {
     try {
-      // This doesn't actually test the connection.
-      db_set_active();
-      // Now actually do a check.
-      Database::getConnection();
+      Database::getConnection('default', NULL, $this->databases);
       $this->pass('Drupal can CONNECT to the database ok.');
     }
     catch (Exception $e) {
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 016ffd0..697165b 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -613,6 +613,8 @@ protected function setUp() {
     // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     drupal_static_reset();
+    // drupal_container() does not use drupal_static().
+    drupal_container(NULL, TRUE);
 
     // Change the database prefix.
     // All static variables need to be reset before the database prefix is
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 8331d55..da2a6e1 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -184,7 +184,7 @@ function system_requirements($phase) {
   else {
     // Database information.
     $class = Database::getConnection()->getDriverClass('Install\\Tasks');
-    $tasks = new $class();
+    $tasks = new $class(drupal_container()->getParameter('database.info'));
     $requirements['database_system'] = array(
       'title' => $t('Database system'),
       'value' => $tasks->name(),
