by Tim Hunt.
It is not an issue with Moodle.
You said you had done:
$CFG->dbport = 'xxxx'
Ken pointed out that the documentation said you should do
$CFG->dboptions = array(
'dbport' => 'xxxx',
);
Have you tried that yet?