diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc
index 7d5d859..e9dd38c 100644
--- a/includes/database/mysql/database.inc
+++ b/includes/database/mysql/database.inc
@@ -37,23 +37,13 @@ class DatabaseConnection_mysql extends DatabaseConnection {
       $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']);
     }
     $dsn .= ';dbname=' . $connection_options['database'];
-    parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
-      // So we don't have to mess around with cursors and unbuffered queries by default.
-      PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE,
-      // Because MySQL's prepared statements skip the query cache, because it's dumb.
-      PDO::ATTR_EMULATE_PREPARES => TRUE,
-      // Force column names to lower case.
-      PDO::ATTR_CASE => PDO::CASE_LOWER,
-    ));
 
     // Force MySQL to use the UTF-8 character set. Also set the collation, if a
     // certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci'
     // for UTF-8.
-    if (!empty($connection_options['collation'])) {
-      $this->exec('SET NAMES utf8 COLLATE ' . $connection_options['collation']);
-    }
-    else {
-      $this->exec('SET NAMES utf8');
+    $init_cmd = "SET NAMES utf8";
+    if (isset($connection_options['collation'])) {
+      $init_cmd .= ' COLLATE ' . $connection_options['collation'];
     }
 
     // Force MySQL's behavior to conform more closely to SQL standards.
@@ -63,7 +53,23 @@ class DatabaseConnection_mysql extends DatabaseConnection {
     // and invalid data handling. See http://drupal.org/node/344575 for
     // further discussion. Also, as MySQL 5.5 changed the meaning of
     // TRADITIONAL we need to spell out the modes one by one.
-    $this->exec("SET sql_mode='ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'");
+    if (isset($connection_options['sql_mode'])) {
+      $init_cmd .= ", sql_mode='" . $connection_options['sql_mode'] . "'";
+    }
+    else {
+      $init_cmd .= ", sql_mode='ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'";
+    }
+
+    parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
+      // So we don't have to mess around with cursors and unbuffered queries by default.
+      PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE,
+      // Because MySQL's prepared statements skip the query cache, because it's dumb.
+      PDO::ATTR_EMULATE_PREPARES => TRUE,
+      // Force column names to lower case.
+      PDO::ATTR_CASE => PDO::CASE_LOWER,
+      // Set connect options such as NAMES, COLLATE, and SQL_MODE
+      PDO::MYSQL_ATTR_INIT_COMMAND => "$init_cmd",
+    ));
   }
 
   public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index a8fe52b..5e86438 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -62,6 +62,7 @@
  *   'port' => 3306,
  *   'prefix' => 'myprefix_',
  *   'collation' => 'utf8_general_ci',
+ *   'sql_mode' => '',
  * );
  * @endcode
  *
@@ -111,6 +112,7 @@
  *   'host' => 'localhost',
  *   'prefix' => 'main_',
  *   'collation' => 'utf8_general_ci',
+ *   'sql_mode' => '',
  * );
  * @endcode
  *
