mysql dead (mysql.sock missing)

kzo

Registered
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.
thanks

kzo
 

fee-5

Registered
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.

--
fee-5

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.
 

kzo

Registered
wow that was simple enough.

thank you
 

Tyler

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.


Tyler


 

rharder

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?

-Rob
 

catnip

Registered
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??

thanks
-Steve
 

slur

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:

su
(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
#!/bin/sh
# startup script for service mysql

. /etc/rc.common

case "$1" in
start)

ConsoleMessage "Starting MySQL database server"

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

;;
esac

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.
 
Top