SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2001
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Promblems with MySQL

    I get this error:
    Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache/htdocs/test.php on line 2

    Unable to connect to the database server at this time.


    Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache/htdocs/test.php on line 10

    Warning: MySQL: A link to the server could not be established in /usr/local/apache/htdocs/test.php on line 10

    Unable to locate the files database at this time.
    The code is:

    PHP Code:
    <?
    $dbcnx 
    mysql_connect("localhost""dummy""");
    if (!
    $dbcnx) {
      echo( 
    "<P>Unable to connect to the " .
            
    "database server at this time.</P>" );
    }else{
      echo( 
    "<p>Success connect to server!!" );
    }

    if (! 
    mysql_select_db("files") ) {
      echo( 
    "<P>Unable to locate the files " .
            
    "database at this time.</P>" );
    }else{
      echo( 
    "<p>Success connect to table!</p>" );
    }
    ?>
    Does anyone have an idea of how I can remidy this?

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sounds like the mySQL server isn't running. If you run 'ps aux|grep mysqld' at the command line, you should see a few entries (other than grep mysqld). If you don't see any then you need to start the server.

  3. #3
    SitePoint Member
    Join Date
    Jun 2001
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Result:
    [root@localhost bin]# ps aux|grep mysqld
    mysql 781 0.0 0.3 11780 1384 ? S 09:21 0:00 /usr/sbin/mysqld
    mysql 801 0.0 0.3 11780 1384 ? S 09:21 0:00 /usr/sbin/mysqld
    mysql 802 0.0 0.3 11780 1384 ? S 09:21 0:00 /usr/sbin/mysqld
    root 1111 0.0 0.1 1624 616 pts/0 S 09:28 0:00 grep mysqld

    I guess it is running... This is really bogging me down.

    -Bob

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm. I get this:
    Code:
    $ ps aux|grep mysqld
    qslack   22397  0.0  0.4   148   476 p3  S+     8:09AM    0:00.00 grep mysqld
    root     11870  0.0  0.3   396   340 q9- I     Wed03PM    0:00.01 /bin/sh /usr/local/mysql/bin/safe_mysqld --user=mysqlusr
    mysqlusr 26960  0.0  1.5 10792  1936 q9- S     Wed03PM    0:03.93 /usr/local/libexec/mysqld --basedir=/usr/local --datadir=/usr/local/var
    Try restarting the server, in case that makes a difference. Also, in netstat -a, do you see anything like this?
    tcp 0 0 *.3306 *.* LISTEN

  5. #5
    SitePoint Member
    Join Date
    Jun 2001
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The difference in output mat be because of variations in OS or version of OS. On the other hand, I figured out what was wrong. The MySQL Deamon was looking for the socket file in my tmp folder, but it acctualy put it in my var/lib/ folder (Don't ask me why...) So I just made a symlink and all is good... Now I can get along with my coding...
    Thank you though.


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
  •