Not sure if you are still working on this issue, but there are two steps that you could perform.
Step 1: Make sure your system is properly configured.
Check if you can connect to your local db by performing:
mysql -u username -p -h yourHost (yourHost is probably localhost)
If you can not connect, you should check some mysql tutorial on how to set up and connect to the database. If you can connect, make sure you have a correct client.ini.php (located in ilias/data/iliasClient) file, should look like this :
[db] <-- This is the section you need to look at
type = "innodb"
host = "yourHost"
user = "user"
pass = "password"
name = "db_name"
structure_reload = "0"
(You might also read up on the following thread: https://www.ilias.de/docu/goto_docu_frm_1875_4446.html)
If this still does not work, you should go to step 2.
Step 2: For custom ports or other non-default configuration
In the following thread there is an issue discussing connections to the db using non-standard ports: https://www.ilias.de/docu/goto_docu_frm_1875_4488.html. Unfortunately in german.
The short version of the solution for this is, that there seems to be an issue connecting to mysql using other than non-default ports. Check the linked thread for the patch file if you are using not a recent version or ILIAS or update to the latest version in git which should solve the issue.