diff --git a/core/register_command.php b/core/register_command.php
index fa85aea8956c249285e8acee870ca137eb045be4..89b0cf31ef462403ec62a53490ceb24948f87ce6 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -83,7 +83,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
 	$application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig()));
 
 	$application->add(new OC\Core\Command\Db\GenerateChangeScript());
-	$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
+	$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getConfig())));
 
 	$application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
 	$application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index a7aae32f670e8aee82f0de87a61dacd2449d0547..8a1ed60b2575ecfdb72a537fe667ce857795364b 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -28,7 +28,7 @@ namespace OC\DB;
 use Doctrine\DBAL\Event\Listeners\OracleSessionInit;
 use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
 use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
-use OC\SystemConfig;
+use OCP\IConfig;
 
 /**
 * Takes care of creating and configuring Doctrine connections.
@@ -65,8 +65,8 @@ class ConnectionFactory {
 		),
 	);
 
-	public function __construct(SystemConfig $systemConfig) {
-		if($systemConfig->getValue('mysql.utf8mb4', false)) {
+	public function __construct(IConfig $config) {
+		if($config->getSystemValue('mysql.utf8mb4', false)) {
 			$defaultConnectionParams['mysql']['charset'] = 'utf8mb4';
 		}
 	}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 063ff4a3d3b65f32d00c607caa2635c491d3cb16..11558118d52379cdfdaf6db3c0d3c3a90b0b00bd 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -408,7 +408,7 @@ class Server extends ServerContainer implements IServerContainer {
 		});
 		$this->registerService('DatabaseConnection', function (Server $c) {
 			$systemConfig = $c->getSystemConfig();
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
+			$factory = new \OC\DB\ConnectionFactory($c->getConfig());
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
 			if (!$factory->isValidType($type)) {
 				throw new \OC\DatabaseException('Invalid database type');
diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php
index 310f74d4c0c1671218cfb5e18dab7632e890cf12..47c3e5ee1c68ae094fd055e3333201996450de6f 100644
--- a/lib/private/Setup/AbstractDatabase.php
+++ b/lib/private/Setup/AbstractDatabase.php
@@ -134,7 +134,7 @@ abstract class AbstractDatabase {
 		}
 
 		$connectionParams = array_merge($connectionParams, $configOverwrite);
-		$cf = new ConnectionFactory();
+		$cf = new ConnectionFactory($this->config);
 		return $cf->getConnection($this->config->getSystemValue('dbtype', 'sqlite'), $connectionParams);
 	}