Can't connect to local MySQL server through socket homebrew

后端 未结 21 1909
萌比男神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:21

    The file /tmp/mysql.sock is probably a Named-Pipe, since it's in a temporary folder. A named pipe is a Special-File that never gets permanently stored.

    If we make two programs, and we want one program to send a message to another program, we could create a text file. We have one program write something in the text file and the other program read what our other program wrote. That's what a pipe is, except it doesn't write the file to our computer hard disk, IE doesn't permanently store the file (like we do when we create a file and save it.)

    A Socket is the exact same as a Pipe. The difference is that Sockets are usually used over a network -- between computers. A Socket sends information to another computer, or receives information from another computer. Both Pipes and Sockets use a temporary file to share so that they can 'communicate'.

    It's difficult to discern which one MySql is using in this case. Doesn't matter though.

    The command mysql.server start should get the 'server' (program) running its infinite loop that will create that special-file and wait for changes (listen for writes).

    After that, a common issue might be that the MySql program doesn't have permission to create a file on your machine, so you might have to give it root privileges

    sudo mysql.server start
    

提交回复
热议问题