--- install.php.orig	2014-02-26 14:39:46.000000000 +0100
+++ install.php	2014-03-11 15:02:46.563229740 +0100
@@ -217,7 +217,14 @@
 
    error_reporting(16);
    echo "<h3>".__('Test of the connection at the database')."</h3>";
-   $link = new mysqli($host, $user, $password);
+
+   //Check if the port is in url
+   $hostport = explode(":", $host);
+   if (count($hostport) < 2) {
+     $link = new mysqli($hostport[0], $user, $password);
+   } else {
+     $link = new mysqli($hostport[0], $user, $password, '', $hostport[1]);
+   }
 
    if (($link->connect_error) || empty($host) || empty($user)) {
       echo "<p>".__("Can't connect to the database")."\n <br>".
@@ -235,9 +242,10 @@
       Html::closeForm();
 
    } else {
-      $_SESSION['db_access'] = array('host'     => $host,
+      $_SESSION['db_access'] = array('host'     => $hostport[0],
                                      'user'     => $user,
-                                     'password' => $password);
+                                     'password' => $password,
+                                     'port'     => $hostport[1]);
       echo  "<h3>".__('Database connection successful')."</h3>";
 
       if ($update == "no") {
@@ -300,6 +308,7 @@
    $host     = $_SESSION['db_access']['host'];
    $user     = $_SESSION['db_access']['user'];
    $password = $_SESSION['db_access']['password'];
+   $port     = $_SESSION['db_access']['port'];
 
    //display the form to return to the previous step.
    echo "<h3>".__('Initialization of the database')."</h3>";
@@ -352,7 +361,14 @@
       $DB->queryOrDie($query, "4203");
    }
 
-   $link = new mysqli($host, $user, $password);
+   //If the port specified
+   if (!empty($port)) {
+     $link = new mysqli($host, $user, $password, $databasename, $port);
+     //Re-form the $host var with the port, this is necessary for the following
+     $host="$host:$port";
+   } else {
+     $link = new mysqli($host, $user, $password, $databasename);
+   }
 
    $databasename = $link->real_escape_string($databasename);
    $newdatabasename = $link->real_escape_string($newdatabasename);
