Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

mysql connect: OK when cron, Not OK when user

Discussion in 'General Discussion' started by ladydi711, Jun 30, 2004.

  1. ladydi711

    ladydi711 Well-Known Member

    Joined:
    Sep 4, 2001
    Messages:
    139
    Likes Received:
    6
    Trophy Points:
    318
    Hi,

    One of my customers has a php script that he has been running via cron. It runs fine and has for some time.

    Now he is trying to debug a database problem and when he tries to run the same php script from ssh, it gives the following error:

    <?
    $link = mysql_connect("localhost", "database", "password");
    if ($link > 0) {
    if (!mysql_select_db("database"))
    $link = -1;
    }
    echo $link . "\n";
    ?>


    <b>Warning</b>: mysql_connect(): Can't connect to local MySQL server
    through socket '/var/tmp/mysql.sock' (2) in
    <b>/home/userdir/public_html/app/x.php</b> on line <b>2</b><br />

    I've seen some threads about my.cnf and mysql.sock, but everything else is working fine, so I'm hesitent to change anything.

    What would cause the difference between running as a cron job and running as the user?

    TIA!
    Diane
     
  2. ladydi711

    ladydi711 Well-Known Member

    Joined:
    Sep 4, 2001
    Messages:
    139
    Likes Received:
    6
    Trophy Points:
    318
    The user account in question was using jailshell. I have given him normal shell access, and mysql can now connect.

    Is is possible to connect to mysql when using jailshell?

    Thanks again!,
    Diane
     
  3. nurseryboy

    nurseryboy Well-Known Member

    Joined:
    Mar 3, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    156
    I'm having the same problem. Disabling jailshell for that account allows the script to run properly. Otherwise, they get the mysql.sock error as well.

    Anyone find a solution? (I know this is an old thread).

    Thanks!
     
  4. nurseryboy

    nurseryboy Well-Known Member

    Joined:
    Mar 3, 2003
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    156
    It looks like running buildapache did the job. Not sure what it was, but everything seems to be ok now.
     
  5. fermar21

    fermar21 Member

    Joined:
    May 21, 2004
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    151
    Location:
    Argentina
    Possible error

    I don't know if this help but the line:
    $link = mysql_connect("localhost", "database", "password");

    Should be:
    $link = mysql_connect("localhost", "username", "password");

    Best regards
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice