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.

Mysql can't connect!

Discussion in 'General Discussion' started by shellie, Sep 4, 2003.

  1. shellie

    shellie Member

    Joined:
    Nov 26, 2002
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Mysql on the server can't connect, this is what I get:

    Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/tmp/mysql.sock' (2) in /home/tenshigi/public_html/b2-include/b2functions.php on line 86
    Can't connect to the database server. MySQL said:
    Can't connect to local MySQL server through socket '/var/tmp/mysql.sock' (2)

    I've tried ln -s /var/tmp/mysql/mysql.sock /var/lib/mysql/mysql.sock to no avail.

    It said no such file or directory exist. What can I do now?

    cPanel.net Support Ticket Number:
     
  2. ciphervendor

    ciphervendor Well-Known Member

    Joined:
    Aug 26, 2002
    Messages:
    1,052
    Likes Received:
    0
    Trophy Points:
    36
    service chksrvd stop
    service mysql stop

    edit /etc/my.cnf

    Make sure that it has the following:
    Code:
    [client]
    port=3306
    socket=/tmp/mysql.sock
    
    [mysqld]
    port=3306
    socket=/tmp/mysql.sock
    If not, then add the above. Save, close and then execute

    service mysql start
    service chksrvd start
    ln -s /tmp/mysql.sock /var/tmp/mysql.sock
    ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

    cPanel.net Support Ticket Number:
     
  3. bmcclure

    bmcclure Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Racine, WI
    chksrvd is not a service on my machine. I have the latest release (158 I think) and everything, but when I try to type service chksrvd stop (or service shksrvd *anything*) it says unrecognized service. Any ideas?

    MySQL crashed with a similar error and won't start, along with FTP and BIND.

    cPanel.net Support Ticket Number:
     
  4. Pilgrim

    Pilgrim Active Member

    Joined:
    Apr 29, 2002
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    I have the same problem on one of my servers.

    I had R158 and downgraded to S117 hoping that would fix the problem.

    nope...

    Mysql is running, users can access their phmyadmin but their programs just no longer can connect to the databases.

    It started today about 2 hours ago

    cPanel.net Support Ticket Number:
     
  5. fgauthier

    fgauthier Member
    PartnerNOC

    Joined:
    Feb 22, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    bmcclure,

    try with

    /etc/rc.d/init.d/chkservd stop

    if you ls -l /tmp/mysql.sock

    are you able to see the file? If not, you need to create the ln -s as suggested above

    cPanel.net Support Ticket Number:
     
  6. bmcclure

    bmcclure Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Racine, WI
    The only mysql.sock on my machine right now is /usr/local/lib/mysql.sock but that's actually mysql.sock@ which I think means it's a link and it apparently points to a non-existent file. The actual mysql.sock file is missing, but shouldn't mysql create that?

    On another note, MySQL is 1/2 up now using the mysql-safe command. It works, for example, in ModernBill and some of my applications, but usage doesn't work in CPanel and PerlDesk doesn't work. Why would this be?

    Thanks guys!

    cPanel.net Support Ticket Number:
     
  7. compunet2

    compunet2 Well-Known Member

    Joined:
    Feb 21, 2003
    Messages:
    310
    Likes Received:
    0
    Trophy Points:
    16
    Same problem here.... mysql.sock missing... It seems to disappear when I do a graceful reboot.

    cPanel.net Support Ticket Number:
     
    #7 compunet2, Sep 15, 2003
    Last edited: Sep 18, 2003
  8. consolutions

    consolutions Registered

    Joined:
    Sep 10, 2003
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I had same problem - appears to be the result of an update to mysql. If you use the "Reset mysql root password" menu pick, it seems to fix the problem.

    cPanel.net Support Ticket Number:
     
  9. bmcclure

    bmcclure Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Racine, WI
    I tried that, and it appeared to work. I no longer get that mysql.sock error, here's what happens when I restart MySQL from WHM:

    Is that OK? MySQL seems to be running, but PerlDesk still can't connect to MySQL, and it used to work fine before this problem.

    Also, still in CPanel instead of the MySQL stats, here's what shows up:

    cPanel.net Support Ticket Number:
     
  10. compunet2

    compunet2 Well-Known Member

    Joined:
    Feb 21, 2003
    Messages:
    310
    Likes Received:
    0
    Trophy Points:
    16
    Does restarting clear the problem?

    cPanel.net Support Ticket Number:
     
  11. bmcclure

    bmcclure Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Racine, WI
    Restarting what? I restarted MySQL. I havent' tried restarting the whole server since I ran the change password thing, no, but I've restarted abotu 5 times since this problem began.

    Should I restart the server? Is ti worth trying?

    Would upgrading to 8.0.0 fix this?

    cPanel.net Support Ticket Number:
     
  12. compunet2

    compunet2 Well-Known Member

    Joined:
    Feb 21, 2003
    Messages:
    310
    Likes Received:
    0
    Trophy Points:
    16
    Restaring the server has been working for me... it seems pretty consistent. Whenever the data center looses power, or I have to do an APC reboot, I get the SQL error. If I then do a graceful reboot, it comes up fine... Give it a try...

    cPanel.net Support Ticket Number:
     
  13. bmcclure

    bmcclure Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Racine, WI
    OK, I figured it out.

    Resetting the mysql password created the mysql.sock file in /tmp, so i went to /var/lib/mysql and created a symbolic link and now everything's up and running again.

    cPanel.net Support Ticket Number:
     
  14. jsoren

    jsoren Member

    Joined:
    Jun 5, 2003
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Confirmed. Same issue. Reset the mysql password and it reported the following:

    ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Mysql password change failed!!
    A forced reset will now be attempted.

    Once it had finished with the restart and set the new password the problem was resolved.

    Now, just as important, what caused this? I would prefer knowing how to prevent it instead of just knowing a quick way to resolve it.

    EDIT: After inspecting the last cron it seems MySQL was updated (from the stable tree) this morning.
     
    #14 jsoren, Mar 10, 2004
    Last edited: Mar 10, 2004
  15. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,426
    Likes Received:
    2
    Trophy Points:
    38
    cPanel Access Level:
    DataCenter Provider
    Make sure all the rpms got installed from the update.

    /scripts/updatenow
    /scripts/sysup
     
  16. cass

    cass Well-Known Member

    Joined:
    Jul 17, 2002
    Messages:
    354
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Argentina/USA/Mexico
    I have everything up to date...
    and I'm also having this problem...
    mysql running, users cant connect... restart dont work...
    I was playing with my.cnf, looks it works now...
    just until it stops working again due to maybe a missing sock file....

    You should make something that actually "checks" not only if mysql is running or if port 3306 is okey...
    but if you can actually CONNECT to the mysql.

    Mysql failing makes big troubles... horde stop working, all forums of all people stop working, etc. we get lot of tickets... you know ;)

    Regards.
     
  17. CoNfOuNd

    CoNfOuNd Member

    Joined:
    Feb 20, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ireland
    service start mysql
    ..didn't work (unrecognizable service) but:
    service start mysqld
    ... did for me!
     
  18. RedFutura

    RedFutura Well-Known Member

    Joined:
    Jun 11, 2003
    Messages:
    72
    Likes Received:
    0
    Trophy Points:
    6
    Same problem here.

    Seems like last cpanel update from the stable tree broke mysql ...

    I have tried resetting the root password with no luck.

    Please give us a good solution to this.
     
  19. richy

    richy Well-Known Member

    Joined:
    Jun 30, 2003
    Messages:
    276
    Likes Received:
    1
    Trophy Points:
    16
    We just had this problem on a WHM 9.1.0 cPanel 9.1.0-R85
    RedHat 7.3 - WHM X v2.1.2 server and just performed ciphervendor's fix of:
     
  20. SiteShack

    SiteShack Member

    Joined:
    Aug 22, 2003
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Please check that the following user/group is assigned for the entire /var/lib/mysql directory

    cd /var/lib
    chown mysql.mysql -R mysql

    once that is set try starting mysql.

    service mysql start

    Hope this helps out.
     
Loading...

Share This Page