Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dunmail

macrumors regular
Original poster
Mar 27, 2009
224
4
Skipton, UK
I have just got my mac back from a repair centre (airport card) and the php scripts on my local copies of are no longer connecting with the mysql database, I get a 2002 error. For some reason my machine hadn't taken any updates so the repair centre forced the machine to take all of them (a lot apparently) and it would appear that one of them has messed things up.

I can access the database via the terminal but the php scripts in my web pages would result in the 2002 error stating: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ .

I've tried several of the "solutions" on the web but now rather than get an error connecting, there is no output from the PHP script in to the web page whatsoever. :(

Any hints?
 
First you need to undo the damage the “solutions” did. Then you need to change the default_socket location (which is extremely likely to be the actual problem).

It is looking for /var/lib/mysql/mysql.sock, it should be looking for: /tmp/mysql.sock.

If you need instructions on how to edit your php.ini file to change the default socket let me know. And certainly if you've never edited a php ini file let me know and I will give you detailed instructions.
 
Sorted!

Actually that was one of the solutions :rolleyes: I was a bit tired last night and wasn't thinking things through logically.

What I hadn't done was to restart the machine rather than just restart the mysql server. Shouldn't have been any different but it was.

I've set all three variants: PDO; mysqli and mysql to use /tmp/mysql.sock

Thanks anyway.
 
Last edited:
Cool, for future reference you just need to restart Apache Web Server, not the machine.
 
I did restart Apache, but not every time I made a change so probably missed doing it when I had the correct solution! Like I said, I was a bit tired last night and not my logical self :eek:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.