Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in

后端 未结 17 2444
长发绾君心
长发绾君心 2020-11-22 08:27

I\'m trying to connect to my MySQL DB with the Terminal on my Apple (With PHP).

Yesterday it worked fine, and now I suddenly get the error in the title.

The

17条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 09:09

    I also had this error, but could only fix it through the suggestion here.

    To summarize, use:

    127.0.0.1
    

    Instead of:

    localhost
    

    The reason is that "localhost" is a special name for the MySQL driver making it use the UNIX socket to connect to MySQL instead of the a TCP socket.

提交回复
热议问题