Can't connect to local MySQL server through socket homebrew

后端 未结 21 1894
萌比男神i
萌比男神i 2020-12-04 05:54

I recently tried installing MySQL with homebrew (brew install mysql) and when I try to run it I get the following error:

ERROR 2002 (HY00

相关标签:
21条回答
  • 2020-12-04 06:35

    Just to add to these answers, In my case I had no local mySQL server, it was running inside a docker container. So the socket file does not exist and will not be accessible for the "mysql" client.

    The sock file gets created by mysqld and mysql uses this to communicate with it. However if your mySql server is not running local, it does not require the sock file.

    By specifying a host name/ip the sock file is not required e.g.

    mysql --host=127.0.0.1 --port=3306 --user=xyz --password=xyz
    
    0 讨论(0)
  • 2020-12-04 06:40

    When you got the server running via

    mysql.server start

    you should see the socket in /tmp/mysql.sock. However, the system seems to expect it in /var/mysql/mysql.sock. To fix this, you have to create a symlink in /var/mysql:

    sudo mkdir /var/mysql

    sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

    This solved it for me. Now my phpMyAdmin works happily with localhost and 127.0.0.1.

    Credit goes to Henry

    0 讨论(0)
  • 2020-12-04 06:40

    Try to connect using "127.0.0.1" instead "localhost".

    0 讨论(0)
提交回复
热议问题