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

后端 未结 17 2054
长发绾君心
长发绾君心 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
    2020-11-22 09:05

    I am on XAMPP on Mac OS X, and Brian Lowe's solution above worked with a slight modification.

    The mysql.sock file is actually in "/Applications/xampp/xamppfiles/var/mysql/" folder. So had to link it up both in /tmp and /var/mysql. I haven't checked which one is used by PHP command line, but this did the fix, so I am happy :-)

    sudo su
    ln -s /Applications/xampp/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock
    mkdir /var/mysql
    ln -s /Applications/xampp/xamppfiles/var/mysql/mysql.sock /var/mysql/mysql.sock
    

提交回复
热议问题