SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Member
    Join Date
    Mar 2001
    Location
    oregon
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Iam running this little script to connect to the msyql server but i keep getting this error MySQL connection failed: Can't Connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in /var/www/html/index1.php on line 8

    Unable to connect to the server.

    <html>
    <head>
    <title> sign up page</title>
    <head>
    <body>
    <?php

    $dbcnx = mysql_connect("localhost","root","fuzzy");
    if (!$dbcnx) {
    echo ( "<P>Unable to connect to the server.</P>");
    exit();
    }

    if (! @mysql_select_db("signup[") ) {
    echo( "<P>Unable to locate sign up.</P>" );
    exit();
    }
    ?>

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a problem with the MySQL server, restart it. Also, there are quite a few threads related to this problem, search on SPF and you'll see.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Member
    Join Date
    Mar 2001
    Location
    oregon
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i restarted mysql and stoped and restarted and it still doesn't work. Ive tried everything mentioned in the forums and it still doesn't work. Any help would be welcomed.

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Are you able to access your MySQL server using the command-line 'mysql' program?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  5. #5
    SitePoint Member
    Join Date
    Mar 2001
    Location
    oregon
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i can do all the command from the commmand line.

  6. #6
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it make a difference if you place the IP of your server rather than localhost. I don't use localhost but rather the IP.

  7. #7
    SitePoint Member
    Join Date
    Mar 2001
    Location
    oregon
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using the servers ip doesn't work either
    i just reinstalled redhat 7 with all packages and i still get that error.

  8. #8
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this code and see if it works...

    PHP Code:
    $dbcnx mysql_connect("localhost","root","fuzzy"); 
    if (!
    $dbcnx) { 
    echo ( 
    "<P>Unable to connect to the server.</P>"); 
    exit(); 


    if (! @
    mysql_select_db("signup") ) { 
    echo( 
    "<P>Unable to locate sign up.</P>" ); 
    exit(); 

    change the appropriet items and try again... you had ab error with a extra bracket ([) where it ought not to have been.

    hope this cures it.. seems you've been through a lot for such a little thing!
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  9. #9
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    exbabylon, that error is well spotted! However, the error is occurring during the call to mysql_connect() (line 8).

    I believe the problem lies in the use of the password "fuzzy" which invokes the Apache fuzzy-logic module which is incompatible with mysql server

    Seriously though...

    1) Try using this address "127.0.0.1" intead of local host.

    2) I'm thinking there also might be a problem with the sockets being used. Isn't the default socket for mysql server 3306 ??? But now I'm talking about stuff I don't really know about

  10. #10
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya... just correct your code... localhost SHOULD work...
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  11. #11
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK then - well, I just looked over my php database connection script that I use on my local linux box. (forgot what was in there because I just always include() it in my php files). It uses the machine's IP address on my LAN "10.0.0.77". If I change the address of the server to "localhost" I can't connect to mysql server either. Same problem with "127.0.0.1" - so my earlier suggestion fails too.

    However, at least I can connect to the mysql server using the machine's IP address. tonyhams can't even do that.

  12. #12
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if he was using the corrupt sript then it WOULDN'T connect no matter what settings he used... but freakysid, you are on a network.. it sounds as though he's on one machine.. so IP shouldn't be requirement... should it? Oh well... mabey... let us know when you get it working.. or not as the case may be... now I'm interested!
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  13. #13
    ********* 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'm a complete idiot! I didn't have the mysql server running when I tested "localhost"

    "localhost"
    "127.0.0.1"
    and the machines network address all work!
    Last edited by freakysid; Mar 15, 2001 at 02:23.

  14. #14
    SitePoint Wizard
    Join Date
    Apr 2000
    Posts
    1,483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    $dbcnx mysql_connect("localhost:3306","root","fuzzy"); 
    if (!
    $dbcnx) { 
    echo ( 
    "<P>Unable to connect to the server.</P>"); 
    exit(); 


    if (! @
    mysql_select_db("signup") ) { 
    echo( 
    "<P>Unable to locate sign up.</P>" ); 
    exit(); 

    Have any settings like the Port been chcanged at all?

  15. #15
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check your /etc/services file to be sure that the proper port is assigned for mysql. Also freakysid could be right with the password issue. I have had issues similar to this in the past.


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
  •