Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4029084
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:18:03+00:00 2026-05-20T11:18:03+00:00

I am trying to set up a PHP framework on my Mac 10.6 computer,

  • 0

I am trying to set up a PHP framework on my Mac 10.6 computer, and it keeps erroring during setup due to database connectivity issues. So I put together a small php script to see if I could connect to the server myself, and it couldn’t either. The operation times out.

However, I am able to login to mysql from commandline perfectly fine. It’s only PHP that is having these connection issues. Does anyone have any ideas?

Here is the script.

<?php
  $connection = mysql_connect("http://localhost", "root", "");
if( $connection ) {
  mysql_close( $connection );
  die('TRUE');
}else {
  die('Could not connect: ' . mysql_error());
}

?>

EDIT: I tried removing http:// but then I get a “No such file error.”

PHP Warning:  mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/newuser/Downloads/t.php on line 2
PHP Warning:  mysql_connect(): No such file or directory in /Users/newuser/Downloads/t.php on line 2
Could not connect: No such file or directory
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:18:03+00:00Added an answer on May 20, 2026 at 11:18 am

    You are using this :

    mysql_connect("http://localhost", "root", "");
    

    But your MySQL host is not http://localhost : it’s probably localhost.

    Try to remove that `http://`, using this :

    mysql_connect("localhost", "root", "");
    

    *As a sidenote : working with the root account is not a good practice — even on a development platform.*

    ———-

    EDIT after the comment : In that case, try with 127.0.0.1 (the IP address of localhost)

    And if you really want to use Unix sockets, you’ll have to find which socket is used by your MySQL server *(it should be indicated in its configuration)* ; for instance, in my `/etc/mysql/my.cnf`, I have :

    [mysqld_safe]
    socket          = /var/run/mysqld/mysqld.sock
    

    Then, you’ll want PHP to use the same one :

    • see the mysql.default_socket directive, about that,
    • or pass it to mysql_connect() as a string such as ':/path/to/socket'
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set up a PHP path to my Zend Framework. I
I'm painfully new to PHP, and was trying to set up phpBB on my
I am relatively new to Cake PHP framework and was trying few things in
I'm trying to set a simple cron script to do some database updating, and
Using PHP 5.3 and Zend Framework 1.11.7 I've been trying to configure the AutoLoader
Where would set_include_path(../../); point to? I am trying to run some PHP code on
I am trying set up databinding as described in the title. The problem I
Trying to set up caching on our datasets - we're using clr stored procedures
Im trying to set up a session and i am getting a header error,
I am trying to set a javascript date so that it can be submitted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.