Tip Details Add a Related Tip

Rate as: Positive Negative

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:

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

Comments on this Tip

Add a Comment
Wow. Thank you. The same thing happened to me not after installing Snow Leopard, but two months later out of nowhere. I slept my mac, woke it up, and Apache no longer would talk to MySQL. I fiddled with MySQL and Apache configuration for a long time and then started googling. Put in "apache not connecting to mysql" into Google and you came up right away. This fixed my problem. Thank you so much!

Brian
– Added by an anonymous user on Oct 19, 2009 at 6:09 pm
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

No apache logs after Snow Leopard upgrade

Categories: Snow Leopard apache
100% positive, 1 comment - last added on Sep 18, 2009 at 10:59 am
– Tip added by an anonymous user on Sep 04, 2009 at 3:58 pm

Increasing PHP session lifetime

Categories: PHP server Apache
100% positive, 0 comments
– Tip added by an anonymous user on Jan 23, 2009 at 12:04 pm

Ignore button not working in Snow Leopard spell checker

100% positive, 0 comments
– Tip added by an anonymous user on Nov 02, 2009 at 12:50 pm

Show the size columns in finder search results

50% positive, 1 comment - last added on Nov 14, 2009 at 4:09 pm
– Tip added by an anonymous user on Oct 25, 2009 at 6:34 am

Snow Leopard Expose shortcuts

100% positive, 0 comments
– Tip added by an anonymous user on Oct 23, 2009 at 12:31 pm

Organizing mailboxes in Snow Leopard

Categories: Mac Snow Leopard Mac
100% positive, 0 comments
– Tip added by an anonymous user on Oct 15, 2009 at 9:03 am

Undeleting trash in Snow Leopard

100% positive, 0 comments
– Tip added by an anonymous user on Oct 01, 2009 at 7:46 am

Put the date in the Snow Leopard menu bar

100% positive, 0 comments
– Tip added by an anonymous user on Sep 30, 2009 at 8:13 am

First PHP Script

no ratings, 0 comments
– Tip added by learnhtmlonline 3 days, 13 hours ago

Turn off dock expose menus in Snow Leopard

no ratings, 0 comments
– Tip added by an anonymous user on Nov 12, 2009 at 5:56 pm

Show links when composing mail on a Mac

no ratings, 0 comments
– Tip added by an anonymous user on Nov 12, 2009 at 7:56 am

black screens when screen sharing in snow leopard

no ratings, 0 comments
– Tip added by an anonymous user on Nov 08, 2009 at 2:29 pm

Change the Expose window higlight color

no ratings, 0 comments
– Tip added by an anonymous user on Nov 06, 2009 at 6:21 am

PHP strftime errors in Smarty

no ratings, 0 comments
– Tip added by an anonymous user on Nov 03, 2009 at 3:04 pm

Copying email address in Snow Leopard

Categories: Mac Snow Leopard Mail
no ratings, 0 comments
– Tip added by an anonymous user on Oct 30, 2009 at 7:06 pm

Shortcut to System Preferences

no ratings, 0 comments
– Tip added by an anonymous user on Oct 29, 2009 at 4:02 pm

Shortcut for secure trash emptying in Snow Leopard

no ratings, 0 comments
– Tip added by an anonymous user on Oct 29, 2009 at 11:26 am

Get dictionary lookup to open in a single window

no ratings, 0 comments
– Tip added by an anonymous user on Oct 17, 2009 at 7:31 am

Alert volumes on a Mac

no ratings, 0 comments
– Tip added by an anonymous user on Oct 14, 2009 at 9:32 am

Disable the guest account in Snow Leopard

Categories: Mac Snow Leopard
no ratings, 0 comments
– Tip added by an anonymous user on Oct 13, 2009 at 12:17 pm