Client programs use the mysql.sock socket to access the mysqld server on Unix and Mac OS X systems (MySQL on Windows uses TCP/IP). Should the client applicationfor example, mysql or a PHP scriptbe unable to find the socket, you'll encounter problems accessing MySQL. There are two reasons why this might occur:
Normally, mysql.sock is stored in the /tmp directory. On some installations, the socket will be in /var/lib/mysql instead. Mac OS X Server puts the MySQL socket in /var/mysql.
You can prevent the first problem by protecting the mysql.sock so that it cannot be deleted.
To protect mysql.sock:
For the second problem, there are two fixes. First, you can tell the client programs where to find mysql.sock. This is editable within the php.ini file, and you can indicate the socket when connecting via the mysql client (Figure A.9). The second option is to create a symbolic link so that where the client thinks the socket should be (e.g., /tmp/mysql.sock) points to where the socket actually is (e.g., /var/mysql/mysql.sock). I'll show you how to do that now.
Figure A.9. I can tell the mysql client where the socket is so that it can communicate with the MySQL server.
To create a symbolic link: