I use two OS X machines to develop my Ruby on Rails application. My desktop works fine, and my laptop was working fine until a few days ago when I got this error when the local server was running on pageload:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I get the same error when I try to run mysql from terminal.
I checked a few other threads, but none of their solutions helped my problem:
Ruby on Rails 3 Can't connect to local MySQL server through socket '/tmp/mysql.sock' on OSX
Can't connect to local MySQL server through socket
The last link the guy seems to be having the exact same problem as I do, but the answer on that page didn't help me since I can't run mysql. I keep seeing this problem online where people fixed it because their .sock file was in the wrong location so I ran
$ ln -s /var/lib/mysql/mysql.sock /tmp
to try to create an alias but it looks like mysql.sock doesn't exist in either place. When I tried running:
$ mysqladmin variables | grep socket
I got this error:
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
Lastly, I turned on invisible files and went looking around my computer, and couldn't find a mysql.sock file or mysql folder in any of the above directories. Once again, mysql WAS working fine on this computer a week ago, and has now inexplicably stopped working for some reason.
How do I restore or recreate my .sock file for this computer?