Error 2002 (hy000): can’t connect to local mysql server through socket ‘/tmp/mysql.sock’ (61) MySQL on MAC OS (Monterrey)

Bruna B.
1 min readJan 31, 2022

I’m setting up a new Rails side project and decided to use MySQL. I had a pretty old version installed, so I decided to uninstall it and install the latest version. This is where my saga begins.

I was having such a hard time finding out why I was getting an “error 2002 (hy000): can’t connect to local mysql server through socket ‘/tmp/mysql.sock’ (61)”.

I simply couldn’t get MySQL to start using brew services start mysql . Apart from a tip where I could trace the actual “permission denied” error, sadly, none of Stackoverflow posts helped me get to the bottom of it.

I genuinely tried everything I could possibly think of, except for one thing: I’ve skipped a lot of what mysql_secure_installation asks thinking it would be just fine. And it wasn’t 🤡

So if you are coming here because you “tried everything”, I suggest you don’t skip any of the questions when installing it. I also, just in case, ran brew unlink mysql && brew link mysqlafter installation.

YAY

--

--

Bruna B.

Software developer, interested in tech, music, stoicism, travelling, & gym.