diff --git a/config/global.ini.php b/config/global.ini.php
index 14e63b444614d3fc58fd0725aa4f5ff7e9ec1ccf..616b3d64c024d3c8ba0cd8e17edd31ff5e8e7c34 100755
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -9,6 +9,7 @@ username		=
 password		= 
 dbname			= 
 tables_prefix	= 
+port			= 3306
 adapter			= PDO_MYSQL ; PDO_MYSQL or MYSQLI
 
 [database_tests]
@@ -17,6 +18,7 @@ username 		= root
 password 		= 
 dbname			= piwik_tests
 tables_prefix	= piwiktests_
+port			= 3306
 adapter 		= PDO_MYSQL
 
 [Language]
diff --git a/modules/LogStats.php b/modules/LogStats.php
index c121fea3ef0d15995a6924b3d11bd4897f0f2d09..2d084c985b70523489802498ac9ab62dacdd4765 100644
--- a/modules/LogStats.php
+++ b/modules/LogStats.php
@@ -87,11 +87,16 @@ class Piwik_LogStats
 		// we decode the password. Password is html encoded because it's enclosed between " double quotes
 		$configDb['password'] = htmlspecialchars_decode($configDb['password']);
 		
+		if(!isset($configDb['port']))
+		{
+			// before 0.2.4 there is no port specified in config file
+			$configDb['port'] = '3306';  
+		}
 		self::$db = new Piwik_LogStats_Db( 	$configDb['host'], 
 										$configDb['username'], 
 										$configDb['password'], 
-										$configDb['dbname']
-							);
+										$configDb['dbname'],
+										$configDb['port'] );
 							  
 		self::$db->connect();
 	}
diff --git a/modules/LogStats/Db.php b/modules/LogStats/Db.php
index 7637b72fdf2a528bc9002a442515b2d7f8f3c5cb..a84e3d58756c4fd361cfabafc8d3dce163514c3b 100644
--- a/modules/LogStats/Db.php
+++ b/modules/LogStats/Db.php
@@ -30,9 +30,9 @@ class Piwik_LogStats_Db
 	/**
 	 * Builds the DB object
 	 */
-	public function __construct( $host, $username, $password, $dbname, $driverName = 'mysql') 
+	public function __construct( $host, $username, $password, $dbname, $port, $driverName = 'mysql') 
 	{
-		$this->dsn = $driverName.":dbname=$dbname;host=$host";
+		$this->dsn = $driverName.":dbname=$dbname;host=$host;port=$port";
 		$this->username = $username;
 		$this->password = $password;
 	}
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index 5f07d3a1704c683c787cd695fa8abbda0cbf5ba3..14956844d4c7ab326448332d67565147fff861f7 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -121,13 +121,17 @@ class Piwik_Installation_Controller extends Piwik_Controller
 				'dbname' 		=> $form->getSubmitValue('dbname'),
 				'tables_prefix' => $form->getSubmitValue('tables_prefix'),
 				'adapter' 		=> Zend_Registry::get('config')->database->adapter,
+				'port'			=> Zend_Registry::get('config')->database->port,
 			);
 			
-			// we test the DB connection with these settings
 			try{ 
-//				var_dump($dbInfos);exit;
 				$dbInfos['password'] = '"'.htmlspecialchars($form->getSubmitValue('password')).'"';
 				
+				if(($portIndex = strpos($dbInfos['host'],':')) !== false)
+				{
+					$dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1 );
+					$dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
+				}
 				Piwik::createDatabaseObject($dbInfos);
 				
 				$_SESSION['db_infos'] = $dbInfos;