Fix mac PHP connection MySQL error warning:mysql_connect (): No such file or directory in conn.php

Source: Internet
Author: User

Today, I used PHP to connect to MySQL database on my Mac, and there was

Mac PHP Warning:mysql_connect (): [2002] No such file ...

Details such as the following are seen:

Dirkmacbook:vote dirk$ PHPUnit mytest.php

Warning:mysql_connect (): No such file or directory in/applications/xampp/xamppfiles/htdocs/myvote/vote/conn.php on Line 25



This error, very easy to overcome this problem, enter such as the following command:

Mkdir/var/mysql

Ln-s/tmp/mysql.sock/var/mysql/mysql.sock



Cause Analysis: PHP will be/var/mysql/below to find Mysql.sock (can be found in the/etc/php.ini configuration file). But this one on our Mac doesn't/var/mysqlz this folder. and Mysql.sock file on/tmp/ Mysql.sock below. What to do?

Very easy, we just need to use ln-s to give/var/mysql/to generate a Mysql.sock file "soft connection" can be.


Fix mac PHP connection MySQL error warning:mysql_connect (): No such file or directory in conn.php

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.