diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 1960874..a43b996 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -1088,6 +1088,16 @@ public function supportsTransactionalDDL() {
    */
   abstract public function databaseType();
 
+  /**
+   * Creates a database.
+   *
+   * In order to use this method, you must be connected without a database
+   * specified.
+   *
+   * @param string $database
+   *   Desired name of database.
+   */
+  abstract public function createDatabase($database);
 
   /**
    * Gets any special processing requirements for the condition operator.
diff --git a/core/lib/Drupal/Core/Database/ConnectionDatabaseDoesNotExistException.php b/core/lib/Drupal/Core/Database/ConnectionDatabaseDoesNotExistException.php
new file mode 100644
index 0000000..0bb3fb0
--- /dev/null
+++ b/core/lib/Drupal/Core/Database/ConnectionDatabaseDoesNotExistException.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * @file
+ * Definition of Drupal\Core\Database\ConnectionDatabaseDoesNotExistException
+ */
+
+namespace Drupal\Core\Database;
+
+use RuntimeException;
+
+/**
+ * Exception thrown if specified database is not found.
+ */
+class ConnectionDatabaseDoesNotExistException extends RuntimeException {}
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
index ae24176..4356332 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
@@ -10,6 +10,7 @@
 use Drupal\Core\Database\DatabaseExceptionWrapper;
 
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\ConnectionDatabaseDoesNotExistException;
 use Drupal\Core\Database\TransactionCommitFailedException;
 use Drupal\Core\Database\DatabaseException;
 use Drupal\Core\Database\Connection as DatabaseConnection;
@@ -24,6 +25,11 @@
 class Connection extends DatabaseConnection {
 
   /**
+   * Error code for "Unknown database" error.
+   */
+  const DATABASE_NOT_FOUND = 1049;
+
+  /**
    * Flag to indicate if the cleanup function in __destruct() should run.
    *
    * @var boolean
@@ -47,7 +53,9 @@ public function __construct(array $connection_options = array()) {
       // Default to TCP connection on port 3306.
       $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']);
     }
-    $dsn .= ';dbname=' . $connection_options['database'];
+    if (!empty($connection_options['database'])) {
+      $dsn .= ';dbname=' . $connection_options['database'];
+    }
     // Allow PDO options to be overridden.
     $connection_options += array(
       'pdo' => array(),
@@ -113,6 +121,29 @@ public function databaseType() {
     return 'mysql';
   }
 
+  /**
+   * Overrides \Drupal\Core\Database\Connection::createDatabase().
+   *
+   * @throws
+   */
+  public function createDatabase($database) {
+    // Escape the database name.
+    // $this->quote() is intended for field values, not database names. It will
+    // therefore put the database name in "quotes" which causes a syntax error
+    // when used here. Use substr() fanciness to remove the beginning and
+    // trailing quotes while leaving the rest of the escaping intact.
+    Database::getConnection()->escapeTable($table);
+
+    try {
+      // Create the database and set it as active.
+      $this->exec("CREATE DATABASE $database");
+      $this->exec("USE $database");
+    }
+    catch (\Exception $e) {
+      throw new ConnectionDatabaseDoesNotExistException($e->getMessage());
+    }
+  }
+
   public function mapConditionOperator($operator) {
     // We don't want to override any of the defaults.
     return NULL;
diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
index 4835103..4010c8e 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
@@ -8,6 +8,9 @@
 namespace Drupal\Core\Database\Driver\mysql\Install;
 
 use Drupal\Core\Database\Install\Tasks as InstallTasks;
+use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Driver\mysql\Connection;
+use Drupal\Core\Database\ConnectionDatabaseDoesNotExistException;
 
 /**
  * Specifies installation tasks for MySQL and equivalent databases.
@@ -33,4 +36,49 @@ public function name() {
   public function minimumVersion() {
     return '5.0.15';
   }
+
+  /**
+   * Checking database connection.
+   */
+  protected function connect() {
+    try {
+      // This doesn't actually test the connection.
+      db_set_active();
+      // Now actually do a check.
+      Database::getConnection();
+      $this->pass('Drupal can CONNECT to the database ok.');
+    }
+    catch (\Exception $e) {
+      // Attempt to create the database if it is not found.
+      if ($e->getCode() == Connection::DATABASE_NOT_FOUND) {
+        // Remove the database string from connection info.
+        $connection_info = Database::getConnectionInfo();
+        $database = $connection_info['default']['database'];
+        unset($connection_info['default']['database']);
+
+        // In order to change the Database::$databaseInfo array, need to remove
+        // the active connection, then re-add it with the new info.
+        Database::removeConnection('default');
+        Database::addConnectionInfo('default', 'default', $connection_info['default']);
+
+        try {
+          // Now, attempt the connection again; if it's successful, attempt to
+          // create the database.
+          Database::getConnection()->createDatabase($database);
+        }
+        catch (ConnectionDatabaseDoesNotExistException $e) {
+          // Still no dice; probably a permission issue. Raise the error to the
+          // installer.
+          $this->fail(st('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage())));
+        }
+      }
+      else {
+        // Database connection failed for some other reason than the database not
+        // existing.
+        $this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
+        return FALSE;
+      }
+    }
+    return TRUE;
+  }
 }
