SOLVED! “Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)”
I got this error yesterday when trying to connect to my mysql database after getting it running with NodeJS. There is a lot of conflicting information on the web due to how you download mysql, versions, which OS you’re on, etc.
For a quick fix on a unix system I suggest doing the following! The steps below worked for me, and can probably work for you, too! However, you will need to install HomeBrew if you don’t have it already.
$ brew doctor
- Make necessary fixes if you haven’t already (this is where I had many directories with screwed up permissions)
- Reinstall mysql to be safe and get latest version
$ brew remove mysql
$ brew install mysql
3. Now you should be good to go!
To Start Your MySQL Connection
$ mysql.server start
To Close Your MySQL Connection
$ mysqld stop
To Open Bash Terminal for Local Development
$ mysql -u root