(OS X 10.6) ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I have recently installed Snow Leopard onto my Mac, and MySQL stopped working. I went into the terminal and used 'rm -r' on my old directory, and redownloaded the new version from the mysql website. I followed all of the instructions on HiveLogic, but am getting the error listed in the title.
When I run 'locate mysql.sock', I don't get any results. 'locate .sock' returns results that down seem like they relate to the problem. My understanding is that I need to restart mysqld, but the instructions that I have found on other questions don't seem to do that for me. How do I restart mysqld?
Solution 1:
You can kill the mysql process manually.
$ ps ax | grep mysql
Note the process id. Then,
$ kill __pid__
Next thing you should do is edit your my.cnf
file, and check to make sure that the socket location is /tmp/mysql.sock
. For example, this is what my [client]
section looks like:
[client]
user=mysql
port=3306
socket=/tmp/mysql.sock
Let's say $MYSQL
is your MySQL folder (in the case of the tutorial you provided, it's probably in /usr/local/mysql/bin
). If you haven't already done so, you have to set up your databases and give your superuser a password.
$ useradd mysql
$ cd $MYSQL
$ ./mysql_install_db
Start MySQL here. Then:
$ ./mysqladmin -u root password '<your_password>'
$ chown -R mysql:mysql /usr/local/mysql/var
Then run sudo ./mysqld_safe --user=mysql &
and you should be set.