diff --git a/autotest.sh b/autotest.sh
index ded3cec6091417e903c5b5e4f7c8162dcd8a99ab..735c6998e05cb681cbb6cc817498fb5762d94b4d 100755
--- a/autotest.sh
+++ b/autotest.sh
@@ -143,6 +143,8 @@ function cleanup_config {
 	if [ -f config/autotest-storage-swift.config.php ]; then
 		rm config/autotest-storage-swift.config.php
 	fi
+	# Remove mysqlmb4.config.php
+	rm -f config/mysqlmb4.config.php
 }
 
 # restore config on exit
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index adb180da0c0131a91d37ea91d9ae81ff1c6ecd9b..1b53cd4b7c0c544877b67cacc0f1a3db86f84fc0 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -25,9 +25,11 @@
  */
 
 namespace OC\DB;
+use Doctrine\Common\EventManager;
+use Doctrine\DBAL\Configuration;
+use Doctrine\DBAL\DriverManager;
 use Doctrine\DBAL\Event\Listeners\OracleSessionInit;
 use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
-use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
 use OCP\IConfig;
 
 /**
@@ -40,30 +42,30 @@ class ConnectionFactory {
 	* Array mapping DBMS type to default connection parameters passed to
 	* \Doctrine\DBAL\DriverManager::getConnection().
 	*/
-	protected $defaultConnectionParams = array(
-		'mysql' => array(
+	protected $defaultConnectionParams = [
+		'mysql' => [
 			'adapter' => '\OC\DB\AdapterMySQL',
 			'charset' => 'UTF8',
 			'driver' => 'pdo_mysql',
 			'wrapperClass' => 'OC\DB\Connection',
-		),
-		'oci' => array(
+		],
+		'oci' => [
 			'adapter' => '\OC\DB\AdapterOCI8',
 			'charset' => 'AL32UTF8',
 			'driver' => 'oci8',
 			'wrapperClass' => 'OC\DB\OracleConnection',
-		),
-		'pgsql' => array(
+		],
+		'pgsql' => [
 			'adapter' => '\OC\DB\AdapterPgSql',
 			'driver' => 'pdo_pgsql',
 			'wrapperClass' => 'OC\DB\Connection',
-		),
-		'sqlite3' => array(
+		],
+		'sqlite3' => [
 			'adapter' => '\OC\DB\AdapterSqlite',
 			'driver' => 'pdo_sqlite',
 			'wrapperClass' => 'OC\DB\Connection',
-		),
-	);
+		],
+	];
 
 	public function __construct(IConfig $config) {
 		if($config->getSystemValue('mysql.utf8mb4', false)) {
@@ -101,14 +103,9 @@ class ConnectionFactory {
 	*/
 	public function getConnection($type, $additionalConnectionParams) {
 		$normalizedType = $this->normalizeType($type);
-		$eventManager = new \Doctrine\Common\EventManager();
+		$eventManager = new EventManager();
 		switch ($normalizedType) {
 			case 'mysql':
-				// Send "SET NAMES utf8". Only required on PHP 5.3 below 5.3.6.
-				// See http://stackoverflow.com/questions/4361459/php-pdo-charset-set-names#4361485
-				$eventManager->addEventSubscriber(new MysqlSessionInit(
-					$this->defaultConnectionParams['mysql']['charset']
-				));
 				$eventManager->addEventSubscriber(
 					new SQLSessionInit("SET SESSION AUTOCOMMIT=1"));
 				break;
@@ -125,9 +122,10 @@ class ConnectionFactory {
 				$eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode));
 				break;
 		}
-		$connection = \Doctrine\DBAL\DriverManager::getConnection(
+		/** @var Connection $connection */
+		$connection = DriverManager::getConnection(
 			array_merge($this->getDefaultConnectionParams($type), $additionalConnectionParams),
-			new \Doctrine\DBAL\Configuration(),
+			new Configuration(),
 			$eventManager
 		);
 		return $connection;
@@ -143,9 +141,11 @@ class ConnectionFactory {
 	}
 
 	/**
-	* @brief Checks whether the specified DBMS type is valid.
-	* @return bool
-	*/
+	 * Checks whether the specified DBMS type is valid.
+	 *
+	 * @param string $type
+	 * @return bool
+	 */
 	public function isValidType($type) {
 		$normalizedType = $this->normalizeType($type);
 		return isset($this->defaultConnectionParams[$normalizedType]);
@@ -160,10 +160,10 @@ class ConnectionFactory {
 	public function createConnectionParams($config) {
 		$type = $config->getValue('dbtype', 'sqlite');
 
-		$connectionParams = array(
+		$connectionParams = [
 			'user' => $config->getValue('dbuser', ''),
 			'password' => $config->getValue('dbpassword', ''),
-		);
+		];
 		$name = $config->getValue('dbname', 'owncloud');
 
 		if ($this->normalizeType($type) === 'sqlite3') {
diff --git a/lib/private/DB/MDB2SchemaReader.php b/lib/private/DB/MDB2SchemaReader.php
index c198bb31e0011572b375c0f3903baaeb5e1ef533..0a51f1b48f22c97305972e13674fff531a2e7495 100644
--- a/lib/private/DB/MDB2SchemaReader.php
+++ b/lib/private/DB/MDB2SchemaReader.php
@@ -34,6 +34,7 @@ namespace OC\DB;
 use Doctrine\DBAL\Platforms\AbstractPlatform;
 use Doctrine\DBAL\Schema\SchemaConfig;
 use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Schema\Schema;
 use OCP\IConfig;
 
 class MDB2SchemaReader {
@@ -77,7 +78,7 @@ class MDB2SchemaReader {
 
 	/**
 	 * @param string $file
-	 * @return \Doctrine\DBAL\Schema\Schema
+	 * @return Schema
 	 * @throws \DomainException
 	 */
 	public function loadSchemaFromFile($file) {
@@ -284,6 +285,7 @@ class MDB2SchemaReader {
 			) {
 				$options['primary'] = true;
 			}
+
 			$table->addColumn($name, $type, $options);
 			if (!empty($options['primary']) && $options['primary']) {
 				$table->setPrimaryKey(array($name));
diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php
index a3535fb33a296969ef91917feb08da8eab4e3cb8..12e83c2b9812f3706d52570d78f7a58dd4f97cac 100644
--- a/lib/private/Repair/Collation.php
+++ b/lib/private/Repair/Collation.php
@@ -67,7 +67,7 @@ class Collation implements IRepairStep {
 	 */
 	public function run(IOutput $output) {
 		if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
-			$output->info('Not a mysql database -> nothing to no');
+			$output->info('Not a mysql database -> nothing to do');
 			return;
 		}
 
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index df3f9e66630d60ac8d4eb2ab9149b54c0cb2c321..82338b40ce5bc27cdf9c903615888a83eac101c6 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -80,13 +80,13 @@ class Setup {
 		$this->random = $random;
 	}
 
-	static $dbSetupClasses = array(
-		'mysql' => '\OC\Setup\MySQL',
-		'pgsql' => '\OC\Setup\PostgreSQL',
-		'oci'   => '\OC\Setup\OCI',
-		'sqlite' => '\OC\Setup\Sqlite',
-		'sqlite3' => '\OC\Setup\Sqlite',
-	);
+	static $dbSetupClasses = [
+		'mysql' => \OC\Setup\MySQL::class,
+		'pgsql' => \OC\Setup\PostgreSQL::class,
+		'oci'   => \OC\Setup\OCI::class,
+		'sqlite' => \OC\Setup\Sqlite::class,
+		'sqlite3' => \OC\Setup\Sqlite::class,
+	];
 
 	/**
 	 * Wrapper around the "class_exists" PHP function to be able to mock it
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index bafb3866b762394afa69fba86b5fdbcf9194464a..f4ba0e7326ad44da414f69bc1f045416b92fa634 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -27,7 +27,6 @@
  */
 namespace OC\Setup;
 
-use OC\DB\ConnectionFactory;
 use OCP\IDBConnection;
 
 class MySQL extends AbstractDatabase {
diff --git a/tests/docker/mysqlmb4/mb4.cnf b/tests/docker/mysqlmb4/mb4.cnf
index 00333eab10ddd78b1c7ba5d1270e36856a92d55c..cb09eac65e3d19e9a13f034f233040813765c27f 100644
--- a/tests/docker/mysqlmb4/mb4.cnf
+++ b/tests/docker/mysqlmb4/mb4.cnf
@@ -3,3 +3,6 @@
 innodb_large_prefix=true
 innodb_file_format=barracuda
 innodb_file_per_table=true
+
+innodb_buffer_pool_size = 512M
+innodb_flush_log_at_trx_commit = 2
diff --git a/tests/lib/DB/MDB2SchemaReaderTest.php b/tests/lib/DB/MDB2SchemaReaderTest.php
index c740eb97f4ba7d34c1902a0b54b9d59f8def71f8..dcec6ae593ee873c1a8b83b3886c729ec5c216f6 100644
--- a/tests/lib/DB/MDB2SchemaReaderTest.php
+++ b/tests/lib/DB/MDB2SchemaReaderTest.php
@@ -10,18 +10,30 @@
 namespace Test\DB;
 
 use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Schema\Schema;
+use OC\DB\MDB2SchemaReader;
+use OCP\IConfig;
+use Test\TestCase;
 
-class MDB2SchemaReaderTest extends \Test\TestCase {
+/**
+ * Class MDB2SchemaReaderTest
+ *
+ * @group DB
+ *
+ * @package Test\DB
+ */
+class MDB2SchemaReaderTest extends TestCase {
 	/**
-	 * @var \OC\DB\MDB2SchemaReader $reader
+	 * @var MDB2SchemaReader $reader
 	 */
 	protected $reader;
 
 	/**
-	 * @return \OC\Config
+	 * @return IConfig
 	 */
 	protected function getConfig() {
-		$config = $this->getMockBuilder('\OCP\IConfig')
+		/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject $config */
+		$config = $this->getMockBuilder(IConfig::class)
 			->disableOriginalConstructor()
 			->getMock();
 		$config->expects($this->any())
@@ -34,7 +46,7 @@ class MDB2SchemaReaderTest extends \Test\TestCase {
 	}
 
 	public function testRead() {
-		$reader = new \OC\DB\MDB2SchemaReader($this->getConfig(), new MySqlPlatform());
+		$reader = new MDB2SchemaReader($this->getConfig(), new MySqlPlatform());
 		$schema = $reader->loadSchemaFromFile(__DIR__ . '/testschema.xml');
 		$this->assertCount(1, $schema->getTables());