January 8, 2003

MySQL Snafu

Somehow my local copy of MySQL has become fubared. Has anyone else experienced this? I’m consistently getting an error which reads, “Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)”. I’m using Marc Liyanage’s MySQL installation which until this evening was working fine so far as I was aware. Thanks in advance for any light which might be shed.

[Update: I’m starting to think that the /tmp/mysql.sock communication socket was somehow deleted since there’s no file by that name. I’ve tried reinstalling the MySQL package. No dice. Grr.]

[Progress: I think I’m starting to get my mind around what went wrong. Somehow the pointer for /tmp -> /private/tmp was replaced by a /tmp directory. I have no idea what did that but I’d sure like to find out. I’m going to try to figure out how to remove the new directory and restablish the pointer.]

[Fixed: So replacing the directory with a symbolic link (essentially, restoring it to the way it should be) seems to have repaired the problem and enabled MySQL (and probably other apps which use /tmp) to run properly again. What a pain.]

Previous Post
Next Post


Brian Poulsen

hmm that sure sounds strange.. I know this is a retard question, but you do remember to start safe_mysqld right ? ;)

Walt Dickinson

Yeah, it keeps crapping out. I looked at the .err file but it wasn’t very helpful. I may try emailing Marc if I can’t get it reinstalled.

Brian Poulsen

nice to see you got the problem solved. BTW, apple has their own official PHP 4.3.0 release. And right now I’m about to take Open Office for a testspin on my mac ;)

Daniel Muniz

Hey man. Safari is causing the problems with tmp folder. See macfixit.com. Seems it likes to delete it, and sometimes the home directory? Anyway, just do a little “ln -s /private/tmp /tmp” Daniel

Daniel Muniz

And get the new Safari update…

Walt Dickinson

Wow that was spot on. Thanks for bringing that to my attention Daniel. I downloaded the new Safari a few minutes ago. I was wondering what the improvements are since there don’t seem to have been any changes to the rendering engine. That sucks that the original Safari had such damaging bugs. Especially since what, 500,000 people have already downloaded it? I hope the new Safari has that shell command built in to repair people’s /tmp links. That command was actually the solution I came to the other day after much research and head-scratching. Thanks again.

how to replace /private/tmp by /tmp directory?

Walt Dickinson

marigoldez: I’m not exactly sure what you’re asking but if you’re experiencing the same problem I had you can replace the improper “/tmp” directory with a symbolic link to “/private/tmp” by typing the command Daniel mentions below into Mac OS X’s Terminal program. You may need to first delete the “/tmp” directory with a command like “rm -r /tmp”. You should make sure there’s nothing important in the “/tmp” directory first of course. You may also need to run both commands as the superuser (by prefixing both commands with “sudo”). Obviously, only do this at your own risk, I can’t offer any promises against any damage this might cause. Here’s the full two step process:

sudo rm -r /tmp sudo ls -s /private/tmp /tmp

yes, same problem as yours.

if something goes wrong, then how to recover this tmp?

mysql ERROR 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

how do i know there exist /tmp or /private/tmp?

from netinfo manager - to check /tmp/ or /private/tmp?

Walt Dickinson

I’m probably not the best person to guide you through this but you should be able to tell if the symbolic link is missing by launching Mac OS X’s Terminal application and typing:

ls -l /

…at the prompt. The command will return the listing of files and directories at the root of your system. You should see:

tmp -> private/tmp

…as one of the symbolically linked directories. If not, follow the steps below to repair it. Keep in mind, this worked for me but it may not work for everyone so please don’t hold me responsible if you mangle your system. Good luck.