The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cPanel Cron job commands can't connect to Database ?!

Discussion in 'Database Discussions' started by jasonsmit, Oct 9, 2014.

  1. jasonsmit

    jasonsmit Member

    Joined:
    Jan 15, 2013
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    I have receiving this following error messages from cpanel running hourly and daily Cronjobs :

    ---------------------
    error massege:
    PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock

    or
    Critical Error : Could not connect to the database

    or

    ERROR OUTPUT:
    mysqldump: Got error: 1045: Access denied for user '***_user'@'localhost' (using password: YES) when trying to connect

    or ......


    ---------------------

    Note: my script can connect to database and mysql fine and no problem there ! and when running these command on root crons haven't problem and running fine there ,

    But php script command can not connect to database correctly under cpanel end user (normal account user) CronJobs, and send me that error messages,

    Please help me to fix ,

    Thanks to all
     
  2. Scriptking

    Scriptking Registered

    Joined:
    Oct 10, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Newcastle, New South Wales, Australia
    cPanel Access Level:
    Root Administrator
    im having same issue, every day i wake up to sql server turned off... i need to login to WHM and re-start it.. its a real pain..

    this is the error i wake up to every day..

    /etc/cron.hourly/modsecparse.pl:

    DBI connect('modsec:localhost','modsec',...) failed: Lost connection to MySQL server at 'handshake: reading inital communication packet', system error: 104 at /etc/cron.hourly/modsecparse.pl line 20
    Unable to connect to mysql database at /etc/cron.hourly/modsecparse.pl line 20.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Check to see if the /tmp/mysql.sock symbolic link exists:

    Code:
    ll /tmp/mysql.sock
    If not, create it via:

    Code:
    ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
    Thank you.
     
  4. jasonsmit

    jasonsmit Member

    Joined:
    Jan 15, 2013
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello Michael,
    Thanks for Your reply

    Both files are exist on the server, but they are empty,

    Please Else solutions?

    Thank You.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    It's likely a limitation of the jailed shell/noshell access applied to the account. Do you experience the same issue when the account is assigned normal shell access?

    Thank you.
     
Loading...

Share This Page