Apache/PHP not connecting to MySQL db after Snow Leopard upgrade
After upgrading to Snow Leopard, my Apache server, running PHP with the MDB2 PEAR extension, was no longer able to connect to the database. Any time it tried to connect I'd get an error like this:
[Tue Sep 08 13:08:05 2009] [error] [client ::1] MDB2 Error: connect failed... connect: [Error message: Can't assign requested address]\n[Native code: 2002]\n[Native message: Can't assign requested address]\n
After a lot of messing around, I found that the problem was in the /etc/php.ini. As part of the upgrade, Snow Leopard conveniently blew away my existing file and created a new one. As part of the new file, it was setting the default socket where I had previously left this empty. The offending lines (spread throughout the php.ini file) were:
Yet on my machine, the /var/mysql directory doesn't even exists. No wonder it couldn't connect!
To solve this, I updated the lines like so:
When you leave them empty like this, it just uses the defaults. After making this change and then restarting my server, I was then able to get Apache/PHP to talk to my MySQL database.
[Tue Sep 08 13:08:05 2009] [error] [client ::1] MDB2 Error: connect failed... connect: [Error message: Can't assign requested address]\n[Native code: 2002]\n[Native message: Can't assign requested address]\n
After a lot of messing around, I found that the problem was in the /etc/php.ini. As part of the upgrade, Snow Leopard conveniently blew away my existing file and created a new one. As part of the new file, it was setting the default socket where I had previously left this empty. The offending lines (spread throughout the php.ini file) were:
pdo_mysql.default_socket = /var/mysql/mysql.sock mysql.default_socket = /var/mysql/mysql.sock mysqli.default_socket = /var/mysql/mysql.sock
Yet on my machine, the /var/mysql directory doesn't even exists. No wonder it couldn't connect!
To solve this, I updated the lines like so:
pdo_mysql.default_socket = mysql.default_socket = mysqli.default_socket =
When you leave them empty like this, it just uses the defaults. After making this change and then restarting my server, I was then able to get Apache/PHP to talk to my MySQL database.
| Rating: | 100% positive, 2 total Votes |
| Categories: | Snow Leopard Apache PHP PEAR |
| Added: | on Sep 08, 2009 at 1:24 pm |
| Added By: | an anonymous user |
| Searches: | snow leopard php pear apache |


Brian