diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 1a3b943..18b60cc 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -9,6 +9,7 @@
 use Drupal\Core\Config\BootstrapConfigStorageFactory;
 use Drupal\Core\Config\NullStorage;
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\DatabaseException;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Core\DependencyInjection\ServiceModifierInterface;
 use Drupal\Core\DependencyInjection\ServiceProviderInterface;
@@ -665,9 +666,43 @@ protected function handleException(\Exception $e, $request, $type) {
       $response->headers->add($e->getHeaders());
       return $response;
     }
-    else {
-      throw $e;
+
+    if (PHP_SAPI !== 'cli' && $this->isNotInstalledException($e)) {
+      return new RedirectResponse($request->getBasePath() . '/core/install.php');
+    }
+
+    throw $e;
+  }
+
+  /**
+   * Determines if the exception is for a missing or not installed database.
+   *
+   * @param \Exception $e
+   *   The exception to check.
+   *
+   * @return bool
+   *   TRUE if the exception is for a missing or not fully installed database,
+   *   FALSE otherwise.
+   */
+  protected function isNotInstalledException(\Exception $e) {
+    if (!($e instanceof \PDOException || $e instanceof DatabaseException)) {
+      return FALSE;
     }
+
+    // Code 1049 is "missing database".
+    if ($e->getCode() == 1049) {
+      return TRUE;
+    }
+
+    // This weird set of conditions is how we detect that the error was the
+    // sessions table was missing, which indicates an uninstalled Drupal.
+    if ($e->getCode() == 0
+        && strpos($e->getMessage(), 'SQLSTATE[42S02]') !== FALSE
+        && strpos($e->getMessage(), 'sessions') !== FALSE) {
+      return TRUE;
+    }
+
+    return FALSE;
   }
 
   /**
