PHP connection MySQL Error "No such file or directory"

Source: Internet
Author: User

    1. The first is to determine the mysql_connect() mysql_pconnect() problem, the fault phenomenon is that the function returns NULL, and mysql_error() returns "No such file or directory".

    2. Write a phpinfo page, find mysql.default_socket , mysqli.default_socket , pdo_mysql.default_socket .

    3. Start MySQL (see note 2), execute command STATUS; Note the value of the UNIX socket.



    4. If the values of 2 and 3 are different, open php.ini (where you can find php.ini from the Phpinfo page, by default /private/etc/php.ini ), and change the value of the three configuration items mentioned in 2 to 3.


      (Note that there are three changes, namely: mysql.default_socket ,, mysqli.default_socket pdo_mysql.default_socket )

    5. Restart Apache.



      OK, here is the mistake to rule out.

PHP connection MySQL Error "No such file or directory"

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.