beatzball
/ blog / article-php-mysql-on-mac-200608130000

PHP/MySQL on the Mac (10.3/10.4)

Published: 2006-08-13

First Enable Apache:

Then edit httpd.conf

#LoadModule php4_module
#AddModule mod_php4.c
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps`

Download and install MySQL for the Mac (10.3, 10.4, etc)

$ sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
$ mysql -u root mysql`
update user set Password=password('_NewPw_‘) where User=’root’;
flush privileges;

How to fix Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’

Apparently, OS X Tiger doesn’t allow for PHP MySQL connection out of the box. You get this: 

Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’

/etc/php.ini(.default) looks for mysql.sock in the wrong place… two options are to make a symbolic link from the right place to the socket…

$ sudo mkdir /var/mysql
$ sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

Or you can update your php.ini (.default) by finding “mysql.default_socket” and setting it to equal /private/tmp/mysql.sock and then restart apache with “apachectl graceful