diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 02bc78fe8af15..d4cb065b9a374 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -56,8 +56,13 @@ public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dbopt throw new dml_exception('dbdriverproblem', $driverstatus); } + if (empty($this->dboptions['dbport'])) { + $dbport = ini_get('mysqli.default_port'); + } else { + $dbport = (int)$this->dboptions['dbport']; + } ob_start(); - $conn = new mysqli($dbhost, $dbuser, $dbpass); /// Connect without db + $conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport); /// Connect without db $dberr = ob_get_contents(); ob_end_clean(); $errorno = @$conn->connect_errno;