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

后端 未结 17 2012
长发绾君心
长发绾君心 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条回答
  •  隐瞒了意图╮
    2020-11-22 08:50

    The reason is that php cannot find the correct path of mysql.sock.

    Please make sure that your mysql is running first.

    Then, please confirm that which path is the mysql.sock located, for example /tmp/mysql.sock

    then add this path string to php.ini:

    • mysql.default_socket = /tmp/mysql.sock
    • mysqli.default_socket = /tmp/mysql.sock
    • pdo_mysql.default_socket = /tmp/mysql.sock

    Finally, restart Apache.

提交回复
热议问题