SOLVED! “Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)”

Devonte M
1 min readOct 29, 2017

--

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
  1. Make necessary fixes if you haven’t already (this is where I had many directories with screwed up permissions)
  2. 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

--

--

Devonte M

Sharing knowledge as I learn it. Big on OOP Javascript, React, Redux, Node, & FUN (the npm module you get in real life) //-> github.com/devontem