diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php
index ee6e534b21ca2fc8a36118204587f8690a267af6..e3bf695dfcd8cc5b339131ed00f7ea6e5f7341fd 100644
--- a/interface/lib/classes/db_mysql.inc.php
+++ b/interface/lib/classes/db_mysql.inc.php
@@ -74,18 +74,15 @@ class db {
 		$this->dbCharset = $conf[$prefix.'db_charset'];
 		$this->dbNewLink = $conf[$prefix.'db_new_link'];
 		$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
-
 		$this->_iConnId = mysqli_init();
-		$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
-		$try = 0;
-		while($this->_iConnId->connect_error && $try < 5) {
-			if($try > 0) sleep(1);
 
-			$try++;
-			$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
+		mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
+		for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
+			sleep($try);
+			mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
 		}
 
-		if($this->_iConnId->connect_error) {
+		if(!is_object($this->_iConnId) || mysqli_connect_error()) {
 			$this->_iConnId = null;
 			$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!');
 			return false;
@@ -244,7 +241,7 @@ class db {
 			$try++;
 			$ok = mysqli_ping($this->_iConnId);
 			if(!$ok) {
-				if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
+				if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
 					if($try > 4) {
 						$this->_sqlerror('DB::query -> reconnect');
 						return false;
diff --git a/server/lib/app.inc.php b/server/lib/app.inc.php
old mode 100755
new mode 100644
index 5016bbc9e2a2710717ff48b8a94a5b398fb1bb64..ce2a5484fcf5efc8671727a954d5897259b8fa2a
--- a/server/lib/app.inc.php
+++ b/server/lib/app.inc.php
@@ -51,7 +51,7 @@ class app {
 					*/
 
 			if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) {
-				$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port']);
+				$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port'], $conf['dbmaster_client_flags']);
 			} else {
 				$this->dbmaster = $this->db;
 			}
diff --git a/server/lib/classes/db_mysql.inc.php b/server/lib/classes/db_mysql.inc.php
index 21e9dc9aa5dbac80707c78baddeeec34850612e6..4eb691ce4422dc6c3683957b3b73f6f0e5c7d4e1 100644
--- a/server/lib/classes/db_mysql.inc.php
+++ b/server/lib/classes/db_mysql.inc.php
@@ -64,7 +64,7 @@ class db
 	*/
 
 	// constructor
-	public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL) {
+	public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL, $flags = NULL) {
 		global $app, $conf;
 
 		$this->dbHost = $host ? $host  : $conf['db_host'];
@@ -74,19 +74,16 @@ class db
 		$this->dbPass = $pass ? $pass : $conf['db_password'];
 		$this->dbCharset = $conf['db_charset'];
 		$this->dbNewLink = $conf['db_new_link'];
-		$this->dbClientFlags = $conf['db_client_flags'];
-
+		$this->dbClientFlags = $flags ? $flags : $conf['db_client_flags'];
 		$this->_iConnId = mysqli_init();
-		$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
-		$try = 0;
-		while($this->_iConnId->connect_error && $try < 5) {
-			if($try > 0) sleep(1);
 
-			$try++;
-			$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
+		mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
+		for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
+			sleep($try);
+			mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
 		}
 
-		if($this->_iConnId->connect_error) {
+		if(!is_object($this->_iConnId) || mysqli_connect_error()) {
 			$this->_iConnId = null;
 			$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!', '', true);
 			return false;
@@ -198,7 +195,7 @@ class db
 			$try++;
 			$ok = mysqli_ping($this->_iConnId);
 			if(!$ok) {
-				if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
+				if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
 					if($this->errorNumber == '111') {
 						// server is not available
 						if($try > 9) {