Configuring non-standard mysql socket

Can anyone tell me how to do this? We have multiple MySQL instances on our server, so instead of the standard /var/lib/mysql/mysql.sock, they use /data/mysql/instance1/mysql.sock, /data/mysql/instance2/mysql.sock etc. From a mysql prompt, I can connect by saying e.g.


mysql -S /data/mysql/instance1/mysql.sock 

How can I specify this in the SuiteCRM configuration?

OK - I got it working by adding the following line to the top of index.php :


ini_set('mysqli.default_socket','/data/mysql/instance1/mysql.sock');

But I really, really do not want to mess around with crucial files like this. If this command is the best way of fixing the problem, is their a better/safer place to put it? And if it cannot be controlled in config.php, can I suggest that it would be a most desirable enhancement to make it so?

Have you tried adding that line to the bottom of the config_override.php file? I am not sure if it will work, but I am pretty sure that file gets loaded when the page loads.

config_override.php loses modifications when you load the Admin->System Settings page.

index.php loses modifications when you perform an upgrade.

So have resorted to putting the ini_set() statement as the first line in config.php.

Any further observations/suggestions welcome.

There seems to be a better solution, which I stumbled on in the course of wondering how I could apply this fix to a fresh, rather than existing, installation. Instead of worrying about the socket, force the application to use the port number to communicate with the database. There appeared to be no way of doing this until I tried altering the config.php file to specify the database host as 127.0.0.1 instead of as “localhost”. In some mysterious way, this makes the application use the port number instead of the socket, so now I am able to remove the "ini_set(‘mysqli.default_socket’ …) line.