To resolve this issue, you can either change the location where MySQL creates its socket file, or modify the location where PHP looks for the file. Please note that the first option is less secure than the second. Before delving in, you should also review new information relevant to PHP and MySQL on Mac OS X Server 10.4.4 and later.
To change the location where MySQL creates its socket file, do this:
- Open your preferred text editor and create a plain text file.
- Type this text (on two lines as shown):
- Save the file as: /etc/my.cnf
To change the location where PHP looks for the socket file, follow these steps:
- In Terminal: sudo cp /etc/php.ini.default /etc/php.ini
- Open /etc/php.ini in your preferred text editor.
- Find the [MySQL] section, and change the mysql.default_socket directive:
; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = /var/mysql/mysql.sock
- Change the permissions on /var/mysql so that www can read the socket, by executing this in Terminal:
sudo chmod 775 /var/mysql