diff -r -u src.org/config.c src/config.c
--- src.org/config.c	2010-02-18 09:48:32.000000000 +0100
+++ src/config.c	2010-02-18 09:49:58.000000000 +0100
@@ -222,6 +222,8 @@
 					strncpy(config->dbname, param, sizeof(config->dbname));
 				else IFIS(line, "server", param)
 					strncpy(config->dbserver, param, sizeof(config->dbserver));
+                                else IFIS(line, "port", param)
+					strncpy(config->dbport, param, sizeof(config->dbport));
 				else IFIS(line, "pidfile", param)
 					strncpy(config->pidfile, param, sizeof(config->pidfile));
 				else IFIS(line, "logfile", param)
diff -r -u src.org/database.c src/database.c
--- src.org/database.c	2010-02-18 09:48:32.000000000 +0100
+++ src/database.c	2010-02-18 14:20:00.000000000 +0100
@@ -40,7 +40,7 @@
 	// Establish our connection to the MySQL Server.
 	mysql = mysql_init(NULL);
 
-	if (!mysql_real_connect(mysql, config->dbserver, config->dbuser, config->dbpass, config->dbname, 0, NULL, 0))
+	if (!mysql_real_connect(mysql, config->dbserver, config->dbuser, config->dbpass, config->dbname, atoi(config->dbport), NULL, 0))
 	{
 		MySAR_print(MSG_ERROR, "mysql_real_connect() in main() %s", mysql_error(mysql));
 	}
@@ -69,6 +69,7 @@
 	char sql[512];
 	char mysql_pwd[50], mysql_user[50], mysql_host[50], mysql_database[50], mysql_client[50];
 	char mysar_pwd[50], mysar_user[50], mysar_grant[50];
+        char mysql_port[5];
 
 
 	MySAR_print(MSG_NOTICE, "WARNING!! This will generate a new database for storing the logs.");
@@ -84,6 +85,7 @@
 	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "Enter MySQL administrative User:     (default: root) ");			MySAR_readconsole(mysql_user);
 	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "Enter MySQL administrative Password: (default: blank) ");		MySAR_readconsole(mysql_pwd);
 	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "Location of the database server:     (default: %s) ", config->dbserver);	MySAR_readconsole(mysql_host);
+	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "Database Port:                       (default: %s) ", config->dbport);  	MySAR_readconsole(mysql_port);
 	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "This Machine Hostname or IP:         (default: localhost) ");		MySAR_readconsole(mysql_client);
 	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "Database name to create:             (default: %s) ", config->dbname);	MySAR_readconsole(mysql_database);
 	MySAR_print(MSG_NOTICE | MSG_NO_CRLF, "MySAR database username:             (default: %s) ", config->dbuser);	MySAR_readconsole(mysar_user);
@@ -92,6 +94,7 @@
 
 	if (mysql_user[0]=='\0') strncpy(mysql_user, "root", sizeof(mysql_user));
 	if (mysql_host[0]=='\0') strncpy(mysql_host, config->dbserver, sizeof(mysql_host));
+	if (mysql_port[0]=='\0') strncpy(mysql_port, config->dbport, sizeof(mysql_port));
 	if (mysql_database[0]=='\0') strncpy(mysql_database, config->dbname, sizeof(mysql_database));
 	if (mysql_client[0]=='\0') strncpy(mysql_client, "localhost", sizeof(mysql_client));
 
@@ -101,7 +104,7 @@
 
 	// Establish our connection to the MySQL Server.
 	mysql = mysql_init(NULL);
-	if (!mysql_real_connect(mysql, mysql_host, mysql_user, mysql_pwd, NULL, 0, NULL, 0)) 
+	if (!mysql_real_connect(mysql, mysql_host, mysql_user, mysql_pwd, NULL, atoi(mysql_port), NULL, 0)) 
 		MySAR_print(MSG_ERROR, "Error connection to the server! MySQL reported: %s", mysql_error(mysql));
 
 	MySAR_print(MSG_NOTICE, "\nDropping any existing databases..");
diff -r -u src.org/mysar.h src/mysar.h
--- src.org/mysar.h	2010-02-18 09:48:32.000000000 +0100
+++ src/mysar.h	2010-02-18 13:00:19.000000000 +0100
@@ -62,6 +62,7 @@
 	char dbpass[25];
 	char dbname[25];
 	char dbserver[127];
+	char dbport[5];
 	char pidfile[127];
 
 	// main configuration filename;

