mysql dead (mysql.sock missing)


The first day I installed this it was running great with apache and php. But now it doesn't run.
When I type >mysql in the terminal it says:
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I did a search using find / -name "mysql.sock" and it doesn't exist. Nothing came up.

I don't know what to do, please help.



Make sure you actually have mysql running.

From the command line:

% ps aux | grep 'mysql'

This will show you all the mysql processes that are currently running.

If the mysql server isn't running:

% safe_mysqld

This will seem to "freeze" the terminal, but that's normal. It means that you've started mysql under that login.

Hope this helps.


PS: Unless you have mysql set up to start every time the box boots, you'll have to restart it manually with "safe_mysqld" every time.


wow that was simple enough.

thank you


Senior Member

If you decide not to have mysql start up automatically when you reboot, a better way to start it is....

% safe_mysqld &

Which will start mysqld as a background process -- leaving your terminal window available for other commands.




Do not read this sign.
Would he have to type "nohup safe_mysqld &" to make sure the process doesn't die when the Terminal window gets closed?



Ok, but I'm getting this same error message, and I do get something back from :

ps aux | grep 'mysql'

and the result is:
steve 1184 0.0 0.1 5768 104 std RV 0:00.01 grep mysql

but, when I try to access my DB, I get:
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

there was a lot of great information about starting the server if it isn't running, but what can I do in my situation? every time I reboot this happens, and I know there's gotta be a way to fix this, isn't there??



Geek / Hedonist
To get any process to start up automatically at boot time you need to include the proper items in the /Library/StartupItems folder. For example, to start MySQL you should do the following:

(root password)

cd /Library/StartupItems

mkdir MySQL

cd MySQL

cat >StartupParameters.plist
Description = "MySQL database server";
Provides = ("MySQL");
Requires = ("Resolver");
OrderPreference = "None";
Messages =
start = "Starting MySQL database server";
stop = "Stopping MySQL database server";
restart = "Restarting MySQL database server";
^D ----- this means press control-D -----

cat >MySQL
# startup script for service mysql

. /etc/rc.common

case "$1" in

ConsoleMessage "Starting MySQL database server"

if [ -x /path/to/safe_mysqld ]; then
/path/to/safe_mysqld &


exit 0
^D ----- this means press control-D -----

chmod 755 MySQL

Voila! Assuming you specified the correct path to safe_mysqld it should do the trick next time you restart.