[FONT=Arial]When running MySQL and PHP on the same Mac OS X 10.4 server, you may find that PHP cannot connect to MySQL. When PHP is communicating with a MySQL server on the same host, it uses a socket file to communicate, and looks for it at /tmp/mysql.sock
. On Mac OS X Server 10.4, MySQL creates this socket file at /var/mysql/mysql.sock
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 informatio
n 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):
e the file as: /etc/my.cnf
e the location where PHP looks for the socket file, follow these steps:
In Terminal: sudo cp /etc/php.ini.default /etc/php.ini
hp.ini in your preferr
ed text editor.
Find the [MySQL] section, and change the mysql.default_socket directive:
; Default socket name for local MySQL connects. If empty, uses
; MySQL defaults.
mysql.default_socket = /var/mysql/mysql.sock
Change the permissions on /var/mysq
l so that www can read the socket, by executi
ng this in Terminal:
sudo chmod 775 /var/mysql