diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc
index 7d5d859..c36070c 100644
--- a/includes/database/mysql/database.inc
+++ b/includes/database/mysql/database.inc
@@ -37,6 +37,26 @@ 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'];
+
+    // Set default init_cmds if not already defined.
+    $init_cmds = "SET ";
+    $init_cmds .= "NAMES " . (empty($connection_options['names']) ? "'utf8'" : $connection_options['names']);
+    $init_cmds .= (empty($connection_options['collation']) ? "," : " COLLATE '" . $connection_options['collation'] . "',");
+    // Set sql_mode to the default if it's not defined.  If it is defined but
+    // empty, then no sql_mode will be set. This allows users to completely
+    // remove sql_mode if needed.
+    $init_cmds .= "sql_mode=" . (empty($connection_options['sql_mode']) ? (isset($connection_options['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'") : "'" . $connection_options['sql_mode'] . "'");
+    // Construct $init_cmds from init_cmds array.  Custom init commands are
+    // applied here.  A list of possible init commands can be found at
+    // http://dev.mysql.com/doc/refman/5.1/en/set-option.html
+    if (isset($connection_options['init_cmds'])) {
+      foreach ($connection_options['init_cmds'] as $init_opt => $init_cmd) {
+        if (!empty($init_cmd)) {
+          $init_cmds .= ",$init_opt $init_cmd";
+        }
+      }
+    }
+
     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,
@@ -44,26 +64,9 @@ class DatabaseConnection_mysql extends DatabaseConnection {
       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_cmds,
     ));
-
-    // 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');
-    }
-
-    // Force MySQL's behavior to conform more closely to SQL standards.
-    // This allows Drupal to run almost seamlessly on many different
-    // kinds of database systems. These settings force MySQL to behave
-    // the same as postgresql, or sqlite in regards to syntax interpretation
-    // 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'");
   }
 
   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..460c94d 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -61,7 +61,6 @@
  *   'host' => 'localhost',
  *   'port' => 3306,
  *   'prefix' => 'myprefix_',
- *   'collation' => 'utf8_general_ci',
  * );
  * @endcode
  *
@@ -110,7 +109,6 @@
  *   'password' => 'password',
  *   'host' => 'localhost',
  *   'prefix' => 'main_',
- *   'collation' => 'utf8_general_ci',
  * );
  * @endcode
  *
@@ -153,6 +151,25 @@
  * @endcode
  * NOTE: MySQL and SQLite's definition of a schema is a database.
  *
+ * You can override the default database init settings such as the names and
+ * collation, sql_mode, and other other variables to be set when constructing
+ * each database connection. If these are not set, defaults are used from the
+ * associated database.inc:
+ * @code
+ * $databases['default']['default'] = array(
+ *   ...
+ *   'names' => 'utf8',
+ *   'collation' => 'utf8_general_ci',
+ *   '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',
+ *   'init_cmds' =>
+ *   array(
+ *     'user_var_name' => 'expr',
+ *   ),
+ * );
+ * @endcode
+ * NOTE: The init_cmds array above provides the ability to add additional
+ * custom connection settings.
+ *
  * Database configuration format:
  * @code
  *   $databases['default']['default'] = array(
