SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't connect to local MySQL server through socket '/tmp/mysql.sock'

    Hello folks.

    I am v. much a beginner here. I've been following the very eloquent Kevin Yanks' tutorial on how to use PHP with MySQL - I have succesfully installed PHP and MySQL on a Mac running OSX, and can run PHP pages through my server, as well as MySQL from command line ..... but cannot connect to server from a PHP page!

    Failure at the first hurdle.

    get following error:

    Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /Library/WebServer/Documents/index.php on line 1


    from the following code:

    $dbcnx = mysql_connect( "localhost", "petermcc", "georgiabassett" );

    help will be greatly appreciated.

    thanks in advance.

    Pete McCabe
    Pete McCabe
    www.digispin.co.uk
    pete@digispin.co.uk

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Possible problems:

    1) You don't have the MySQL server running on your machine. It needs to be started independently of apache & php.

    2) You have mysql and php configured to use different TCP ports. I think the default port for MySQL is 3306.

    BTW, don't post any passwords to public forums

  3. #3
    SitePoint Enthusiast bsmith@interinc.com's Avatar
    Join Date
    Jun 2001
    Location
    Maryland, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Same here

    I am having the same problem as I cut and pasted the

    (?php yada yada yada ?) from the tutorial.

    I am I, Therefore I bark.

  4. #4
    SitePoint Enthusiast bsmith@interinc.com's Avatar
    Join Date
    Jun 2001
    Location
    Maryland, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Port Starting?

    Sorry for jumping in again but I need a better understanding as I am suffering from the same error.

    When you say that it doesn't start with apache am I supposed to start it with the PHP?

    Can you write an example?

    Still
    I am I, Therefore I bark.

  5. #5
    SitePoint Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freakysid
    Possible problems:

    1) You don't have the MySQL server running on your machine. It needs to be started independently of apache & php.

    2) You have mysql and php configured to use different TCP ports. I think the default port for MySQL is 3306.

    BTW, don't post any passwords to public forums
    Nice one. (no worries about the password as the server isn't going online .. unless that's naive ...)

    cheers
    Pete McCabe
    www.digispin.co.uk
    pete@digispin.co.uk

  6. #6
    SitePoint Enthusiast Ckeren's Avatar
    Join Date
    Jun 2001
    Location
    AU
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hemmmmm

  7. #7
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not run Apache/PHP/MySQL on windoze, so I'm sorry if my suggestions are vague

    1) MySQL server needs to be running. Just like the Apache exe needs to be running for it to serve pages, there should be a MySQL exe that you need to have running so that the server is running and a socket is open waiting to take requests.

    2) The port setting - don't worry about what I said. If you haven't gone messing around with the MySQL settings in php.ini then the defaults should be fine.

    3) Of course you need to ensure that in the users table in mysql, you have a record for the userid and pword you are trying to connect with.

    Sorry I can't be of any more help. Someone with better windoze experience will come along sooner and later probably with more pertinent advice.

  8. #8
    SitePoint Enthusiast bsmith@interinc.com's Avatar
    Join Date
    Jun 2001
    Location
    Maryland, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    windoze

    Thanks for the input...

    What do you use as an interface to create your db?

    I am I, Therefore I bark.

  9. #9
    SitePoint Enthusiast bsmith@interinc.com's Avatar
    Join Date
    Jun 2001
    Location
    Maryland, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Windoze

    I'm not running Apache/PHP/MySQL on Win I am on a Linux, my problem is getting my client, (Mac and or PC) to use an interface to create and update an db. How do you do your's? I am new so I just learnrd howe to Telnet a db in and am currently building it.

    My problems are, thus far getting a PHP statement toopen it...I used the.....

    <?php
    // Connect to the database server $dbcnx = @mysql_connect("localhost", "root", "mypasswd"); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); }
    // Select the jokes database if (! @mysql_select_db("jokes") ) { echo( "<P>Unable to locate the joke " . "database at this time.</P>" ); exit(); }
    ?>

    And changed the info to reflect mine but it didn't work...

    I can use the "Today's date" PHP and tell the time on my Server with the PHP but some scripts don't work? I think I am missing something, huh?
    I am I, Therefore I bark.

  10. #10
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi again.

    - when you post your code put it inside vBulletin's tags for php:
    [ p h p ] and [ / p h p ]
    except remove the white spaces (I put them in to trick vBulletin).

    - Remove the @ in front of you mysql function calls - at least while you are developing. This turns error reporting on for those functions and you will get meaningful error details printed to your browser window.

    - You can see whether the mysql server daemon is running by looking to see whether the file /tmp/mysql.sock is present in the tmp directory. If it isn't then you need to start MySQL. I'm not sure how you have MySQL set up on your machine. On mine the path to the MySQL binaries is:

    /usr/local/mysql/bin

    Probably not the correct place, but who knows - I'm a linux newbie myself. Anyway, you need to start the mysql server daemon:

    usr/local/mysql/bin/mysql.server start

    - Umm, I'm thinking of what else could be the problem. When you install PHP you have to configure it to include MySQL support. You have to have something like so in your configure command:

    ./configure --with-mysql=path/to/mysql

    I hope you can get it sorted out. The first time I installed MySQL and PHP, I did it by downloading the www.nusphere.com bundle. It sets everything up sweet.

  11. #11
    SitePoint Enthusiast bsmith@interinc.com's Avatar
    Join Date
    Jun 2001
    Location
    Maryland, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    VBulletin?

    What's vbulletin? When you say [ p h p ] and [ / p h p ]

    What do you mean?

    Can you take the script from the post and make example? I understand the removing the @ part. I think I am newer to Linux then you.

    I think my MySQL server is running, do you have a script I can use to test it? Something that you have used....

    Big Thanks
    I am I, Therefore I bark.

  12. #12
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBulletin is the forum software these forums are running. It uses php/mysql BTW. So if you type your post up like so (remove the whitespace from the php tags):
    [ p h p ]
    <?php
    echo "hello";
    ?>
    [ / p h p ]

    It will look like this:
    PHP Code:
    <?php
    echo "hello";
    ?>
    Except that it is hard to follow (because vBulletin has stripped the formatting), you code looks fine. What exaclty is the error you are getting?

    Umm, here is a checklist of potential problems:
    - PHP was not configured with MySQL,
    - MySQL not running (no /tmp/mysql.sock file).
    - User root has not been created within MySQL.
    - Database jokes has not been created within MySQL.

    You should try and log into mysql from the bash shell.

    /path/to/mysql/bin/mysql -u root -p

    This will then prompt you for your password. If you don't get past this point then user root does not have permission to access the mysql server.

    If you succeed then type in:

    use jokes;

    And hopefully that will go ok. Otherwise there is no jokes database.

    If all the above goes ok - and mysql is working from the command line, then you know that the problem is with your php configuration.

  13. #13
    SitePoint Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: windoze

    Originally posted by bsmith@interinc.com
    Thanks for the input...

    What do you use as an interface to create your db?

    hello there - just to say I've followed freakysid's advice and I am fully up and running ... as for the interface, the tutorial (Kevin's) from this site already has me with an html based interface for building my db - only one table so far ... but I only just started ... or are you talking about something more sophisticated?

    PS Respect to freakysid ...
    Pete McCabe
    www.digispin.co.uk
    pete@digispin.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •