mysql on a nondefault socket

It is sometimes necessary to run two instances of mysql, like in my case. I need a mysql database in addition to the one Zimbra uses. One solution to this problem is to run the mysql database on a non default socket. This can be done by changing the following line in my.cnf

my.cnf

[client]
...
socket = /var/run/mysqld/mysqld2.sock

Restart the mysql daemon afterwards to activate the change.

In PHP it’s possible to avoid programming the nondefault socket info whenever we use mysql
php.ini

[MySQL]
...
mysql.default_socket = /var/run/mysqld/mysqld2.sock

If you don’t have access to php.ini you have to program this in your PHP code

$dbcnx = @mysql_connect('localhost:/var/run/mysqld/mysqld2.sock',$username, $password);