4

When just installing mysql on OSX through homebrew like so: brew install mysql and I try to run the command mysql_secure_installation as brew suggests, it just gives me the following error:

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

I tried ALL SOLUTIONS from this thread: Can't connect to local MySQL server through socket homebrew

But alass nothing solved my problem. Any advice to debug?

When I try to check the existance of the socket file:
ls -al /tmp/mysql.sock
It says: No such file or directory.

Did Homebrew maybe forget to install something?

Community
  • 1
  • 1
mesqueeb
  • 5,277
  • 5
  • 44
  • 77
  • Did you start the mysql server? –  Jul 13 '16 at 04:27
  • Yes I did. `mysql.server start` – mesqueeb Jul 13 '16 at 04:29
  • 1
    @ShivaShinde When I try to check the existance of the socket file: `ls -al /tmp/mysql.sock` It says: No such file or directory. – mesqueeb Jul 13 '16 at 04:33
  • Could you check whether your /etc/my.cnf or /etc/mysql/my.cnf has socket defindd in the below manner? `[client] socket=/var/lib/mysql/mysql.sock` –  Jul 13 '16 at 04:34
  • 1
    Tried looking for both files. Again, they do not exist. Maybe `brew install mysql` didn't work properly? Did it forget to install certain files you think? – mesqueeb Jul 13 '16 at 04:37

1 Answers1

6

Often this is because of permissions, did you try?

sudo chown -R _mysql:mysql /usr/local/var/mysql

sudo mysql.server start
  • OMG! This worked! You saved me. I lost 2 hours lol. I tried `mysql_secure_installation` again, and now it works. – mesqueeb Jul 13 '16 at 04:40