January 5

PHP & MySQL on Leopard: mysql.sock Location

One thing I noticed setting up PHP and MySQL on Leopard, is that the default PHP build looks for the MySQL socket in /var/mysql/mysql.sock which doesn’t exist and isn’t the location that MySQL would use if it did (by default anyway). By default the MySQL socket is: /tmp/mysql.sock.
There are four ways to fix this:
Create the /var/mysql directory (sudo mkdir /var/mysql) and then create a symbolic link from /tmp/mysql.sock to /var/mysql/mysql.sock (with: sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock).
Edit the /etc/php.ini file (it may not exist in which case just sudo cp /etc/php.ini.default /etc/php.ini) so that the mysql.default_socket = /tmp/mysql.sock (by default line 760) and mysqli.default_socket = /tmp/mysql.sock (by default line 795).
Edit /etc/my.cnf adding the following lines:

[mysqld]
socket=/var/mysql/mysql.sock
[client]
socket=/var/mysql/mysql.sock

This will tell MySQL to create its socket where Leopard’s default PHP is looking for it. Next, you also need to create the /var/mysql directory and sudo chown mysql /var/mysql it or MySQL won’t start since it wont be able to create the socket.
Recompile php for your version of MySQL (a PIA, but not a terrible idea at all).
Of these #1 is easiest, but a bit of a hack. #2 is the easiest real way. #3 isn’t to bad, but could cause issues with other MySQL clients that look for the socket in /tmp/mysql.sock. #4 is ultimately the best fix, but is clearly neither very fast nor particularly easy

Category: Mac, Technical | Comments Off on PHP & MySQL on Leopard: mysql.sock Location
January 4

Mac OS X Server version 10.5: MySQL libraries available for download

Issue or symptom
MySQL client libraries and headers are not included with Mac OS X Server 10.5. If you are developing a MySQL client application for Mac OS X 10.5, you’ll need to download the MySQL client libraries and headers.
Solution
The MySQL client libraries and headers are available for download and installation from (http://www.opensource.apple.com/darwinsource/Current/).
The MySQL sources are available from (http://www.opensource.apple.com/darwinsource/tarballs/other/MySQL-43.tar.gz), and also include instructions on using the supplied Makefile.
A binary download that can be installed on Leopard Server is available from (http://www.opensource.apple.com/darwinsource/other/MySQL-43.binaries.tar.gz).

Category: Mac, Technical | Comments Off on Mac OS X Server version 10.5: MySQL libraries available for download