1
votes

I just installed mySQL and when I try to type mysql in my mac terminal I'm getting

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I tried searching for an answer but I'm still stuck. Also, I don't know if this is relevant or connected, but when I go to my preference panel to try to start mySQL it doesn't start. On some sites such as other stackoverflow pages, it says to try running "/usr/local/mysql/bin/mysqld_safe" but for me it just permission denied..

I tried to do ps -u mysql to check if it's running and it printed out and an address: usr/local/mysql/bin/mysqld --basedir=/usr/local. So I assume it's running? Even though I can't physically press the button and enable it in the preference panel which is weird.

EDIT: I typed

$ sudo /usr/local/mysql/bin/mysqld_safe

Password:

130930 11:55:15 mysqld_safe Logging to '/usr/local/mysql/data/myname-mac.att.net.err'. 130930 11:55:15 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data 130930 11:55:18 mysqld_safe mysqld from pid file /usr/local/mysql/data/myname-mac.att.net.pid ended

why did it end right there?

2
Reads like your MySQL server isn't running. You'll need to get it started (see @ExplosionPills' comment)AlG
I typed: $ sudo /usr/local/mysql/bin/mysqld_safe. See above edit.user2827592

2 Answers

1
votes

I had this same error message for days and finally figured it out.

I had somehow gotten a my.cnf file on my computer from AMPS or possibly another MYSQL install (that I believed I had deleted).

But it turns out it was a hidden file in /etc/ that I had to manually delete. http://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/

Finally, I installed MySQL with homebrew one more time –– and success! It works. Also of course this time I spot a message in the homebrew setup process that points out the problem I was having:

A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly.

Hope this helps.

0
votes

I also experienced a similar error. After trying all prescribed solutions like in this related post, noticed that it was a simple solution: first make sure the mysql daemon is running. For example, on a Homebrew installation (macOS), start mysql with: brew services start mysql