diff --git a/html/inc/db_conn.inc b/html/inc/db_conn.inc
index d45a95ebb1..ba4d827da5 100644
--- a/html/inc/db_conn.inc
+++ b/html/inc/db_conn.inc
@@ -27,10 +27,17 @@ class DbConn {
function init_conn($user, $passwd, $host, $name) {
if (MYSQLI) {
- if (version_compare(PHP_VERSION, '5.3.0') < 0) {
- $this->db_conn = new mysqli($host, $user, $passwd);
+ $x = explode($host, ":");
+ if (sizeof($x)>1) {
+ $host = $x[0];
+ $port = $x[1];
} else {
- $this->db_conn = new mysqli("p:".$host, $user, $passwd);
+ $port = null;
+ }
+ if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ $this->db_conn = new mysqli($host, $user, $passwd, $name, $port);
+ } else {
+ $this->db_conn = new mysqli("p:".$host, $user, $passwd, $name, $port);
}
global $mysqli;
$mysqli = $this->db_conn;
diff --git a/py/Boinc/database.py b/py/Boinc/database.py
index 1d791db380..f73807391c 100644
--- a/py/Boinc/database.py
+++ b/py/Boinc/database.py
@@ -255,8 +255,17 @@ def connect(config = None, nodb = False):
db = config.db_name
host=config.__dict__.get('db_host','')
+ port=""
+ if ':' in host:
+ host,port=config.__dict__.get('db_host','').split(":")
+
+ if port == '':
+ port = 3306
+ else:
+ port = int(port)
do_connect(db=db,
host=host,
+ port=port,
user=config.__dict__.get('db_user',''),
passwd=config.__dict__.get('db_passwd', ''))
return 1
diff --git a/py/Boinc/db_base.py b/py/Boinc/db_base.py
index 01c8bbd608..432bbc1dc3 100644
--- a/py/Boinc/db_base.py
+++ b/py/Boinc/db_base.py
@@ -488,14 +488,15 @@ class DatabaseObject:
def _set_dirty(self, value=True):
self.__dict__['_dirty'] = value
-def do_connect(db, user, passwd, host='localhost'):
+def do_connect(db, user, passwd, port, host='localhost'):
"""Takes a database name, a username, and password. Connects to
SQL server and makes a new Dbconnection."""
global dbconnection
if dbconnection:
raise 'Already connected'
- dbconnection = MySQLdb.connect(db=db,host=host,user=user,passwd=passwd,
- cursorclass=MySQLdb.cursors.DictCursor)
+ dbconnection = MySQLdb.connect(db=db, host=host, port=port, user=user,
+ passwd=passwd, cursorclass=MySQLdb.cursors.DictCursor)
+
def close():
"""Closes the connection to the sql survey and deletes the Dbconnection object."""
global dbconnection