diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php
index ee9c23e..9cbd50f 100644
--- a/core/lib/Drupal/Core/Database/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\Core\Database\Install;
 
-use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Database;
 
 /**
@@ -148,14 +147,19 @@ public function runTasks() {
       }
     }
     // Check for failed results and compile message
-    $message = '';
+    $errors = [];
     foreach ($this->results as $result => $success) {
       if (!$success) {
-        $message = SafeMarkup::isSafe($result) ? $result : SafeMarkup::checkPlain($result);
+        $errors[] = $result;
       }
     }
-    if (!empty($message)) {
-      $message = SafeMarkup::set('Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="https://www.drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider.' . $message);
+    if ($errors) {
+      $error_list = [
+        '#theme' => 'item_list',
+        '#items' => $errors,
+      ];
+      $error_list = \Drupal::service('renderer')->renderPlain($error_list);
+      $message = t('Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="https://www.drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider.@errors', ['@errors' => $error_list]);
       throw new TaskException($message);
     }
   }
diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php
index c340c92..1bb3a4a 100644
--- a/core/modules/simpletest/src/InstallerTestBase.php
+++ b/core/modules/simpletest/src/InstallerTestBase.php
@@ -137,34 +137,6 @@ protected function setUp() {
 
     // Configure site.
     $this->setUpSite();
-
-    // Import new settings.php written by the installer.
-    $request = Request::createFromGlobals();
-    $class_loader = require $this->container->get('app.root') . '/autoload.php';
-    Settings::initialize($this->container->get('app.root'), DrupalKernel::findSitePath($request), $class_loader);
-    foreach ($GLOBALS['config_directories'] as $type => $path) {
-      $this->configDirectories[$type] = $path;
-    }
-
-    // After writing settings.php, the installer removes write permissions
-    // from the site directory. To allow drupal_generate_test_ua() to write
-    // a file containing the private key for drupal_valid_test_ua(), the site
-    // directory has to be writable.
-    // WebTestBase::tearDown() will delete the entire test site directory.
-    // Not using File API; a potential error must trigger a PHP warning.
-    chmod($this->container->get('app.root') . '/' . $this->siteDirectory, 0777);
-    $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
-    $this->kernel->prepareLegacyRequest($request);
-    $this->container = $this->kernel->getContainer();
-    $config = $this->container->get('config.factory');
-
-    // Manually configure the test mail collector implementation to prevent
-    // tests from sending out e-mails and collect them in state instead.
-    $config->getEditable('system.mail')
-      ->set('interface.default', 'test_mail_collector')
-      ->save();
-
-    $this->isInstalled = TRUE;
   }
 
   /**
@@ -196,11 +168,39 @@ protected function setUpSettings() {
   }
 
   /**
-   * Installer step: Configure site.
+   * Final installer step: Configure site.
    */
   protected function setUpSite() {
     $edit = $this->translatePostValues($this->parameters['forms']['install_configure_form']);
     $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
+
+    // Import new settings.php written by the installer.
+    $request = Request::createFromGlobals();
+    $class_loader = require $this->container->get('app.root') . '/autoload.php';
+    Settings::initialize($this->container->get('app.root'), DrupalKernel::findSitePath($request), $class_loader);
+    foreach ($GLOBALS['config_directories'] as $type => $path) {
+      $this->configDirectories[$type] = $path;
+    }
+
+    // After writing settings.php, the installer removes write permissions
+    // from the site directory. To allow drupal_generate_test_ua() to write
+    // a file containing the private key for drupal_valid_test_ua(), the site
+    // directory has to be writable.
+    // WebTestBase::tearDown() will delete the entire test site directory.
+    // Not using File API; a potential error must trigger a PHP warning.
+    chmod($this->container->get('app.root') . '/' . $this->siteDirectory, 0777);
+    $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
+    $this->kernel->prepareLegacyRequest($request);
+    $this->container = $this->kernel->getContainer();
+
+    // Manually configure the test mail collector implementation to prevent
+    // tests from sending out e-mails and collect them in state instead.
+    $this->container->get('config.factory')
+      ->getEditable('system.mail')
+      ->set('interface.default', 'test_mail_collector')
+      ->save();
+
+    $this->isInstalled = TRUE;
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Installer/InstallerDatabaseErrorMessagesTest.php b/core/modules/system/src/Tests/Installer/InstallerDatabaseErrorMessagesTest.php
new file mode 100644
index 0000000..2452c40
--- /dev/null
+++ b/core/modules/system/src/Tests/Installer/InstallerDatabaseErrorMessagesTest.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\system\Tests\Installer\InstallerDatabaseErrorMessagesTest.
+ */
+
+namespace Drupal\system\Tests\Installer;
+
+use Drupal\Core\Database\Database;
+use Drupal\simpletest\InstallerTestBase;
+
+/**
+ * Tests the installer with database errors.
+ *
+ * @group Installer
+ */
+class InstallerDatabaseErrorMessagesTest extends InstallerTestBase {
+
+  /**
+   * @{inheritdoc}
+   */
+  protected function setUpSettings() {
+    // We are creating a table here to force an error in the installer because
+    // it will try and create the drupal_install_test table as this is part of
+    // the standard database tests performed by the installer in
+    // Drupal\Core\Database\Install\Tasks.
+    Database::getConnection('default')->query('CREATE TABLE {drupal_install_test} (id int NULL)');
+    parent::setUpSettings();
+  }
+
+  /**
+   * @{inheritdoc}
+   */
+  protected function setUpSite() {
+    // This step should not appear as we had a failure on the settings screen.
+  }
+
+  /**
+   * Verifies that the error message in the settings step is correct.
+   */
+  public function testSetUpSettingsErrorMessage() {
+    $this->assertRaw('<ul><li>Failed to <strong>CREATE</strong> a test table');
+  }
+
+}
