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.

Error while connecting to MYSQL - Can’t connect to a local MySQL server through socket

Discussion in 'Database Discussions' started by Carmstrongclark, Jun 11, 2016.

  1. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    A few weeks ago our sites example.com & domain.com ran into an issue regarding the MySql databases. My only solution to fix them was to delete the cpanel sites and restore the sites back to a time when they worked. I thought it had solved the issue, however after a few days of running normally they have both ran in the following errors in MySql:


    Code:
    [B]The system will redirect you in amoment. Error while connecting to MYSQL: (XID u878g3) Can’t connect to a local MySQL server through socket ‘/var/lib/mysql/mysql.cok’ (2)Error while connecting to MySQL: (XID u878g3) Can’t connect to local MySQL server through socket ‘var/lib/mysql/mysql.sock’ (2) at /usr/local/cpanel/Cpanel/Mysql.pm line 181.[/B]

    I have tried rebooting the server but that didn't work either. I will delete the cpanel site of example.com but domain will remain incase anyone wanted to see how it currently sits. It's a weird issue and one I can't figure out so thanks in advance.
     
    #1 Carmstrongclark, Jun 11, 2016
    Last edited by a moderator: Jun 11, 2016
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,478
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    I don't think deleting and restoring is fixing, TBH. You might check to make sure MySQL is up and running. If it is and you can connect to your site(s) as expected, great. What's killing your mysql.sock? Sounds like that's whats happening. Guessing of course.

    Are you manually clearing tmp for some reason?
     
  3. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner

    Ha Yeah, sorry it most definitely isn't a fix. But I though it was something I had done. I ha. It is now saying that MySQL is currently offline - however when I restart MySql the problem still remains. Apologies as I'm quite new to all of this so learning as I go.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,478
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    What message do you get when trying to restart MySQL exactly?
     
  5. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Hi thanks for replying:

    When restarting MySQL via WHM I get the following messages:

    Code:
    [B]Waiting for “mysql” to start ……waiting for “mysql” to initialize ………finished.
    
    Startup Log
    Starting MySQL... SUCCESS! 
    
    Log Messages
    160612 4:42:50 [Note] /usr/sbin/mysqld: ready for connections.
    160612 04:42:48 mysqld_safe mysqld restarted
    160612 04:42:48 mysqld_safe Number of processes running now: 0
    /usr/sbin/mysqld[0x84f4a2]
    /usr/sbin/mysqld[0x859dfa]
    /usr/sbin/mysqld[0x91d4a2]
    /usr/sbin/mysqld[0x928fd8]
    /usr/sbin/mysqld[0x928acf]
    /usr/sbin/mysqld[0x885508]
    /usr/sbin/mysqld[0x8d214b]
    /usr/sbin/mysqld[0x8d1c9a]
    160612 4:42:48 [Note] /usr/sbin/mysqld: ready for connections.
    160612 04:42:45 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    160611 08:02:39 mysqld_safe mysqld from pid file /var/lib/mysql/s45-40-136-69.secureserver.net.pid ended
    /usr/sbin/mysqld[0x84f4a2]
    /usr/sbin/mysqld[0x859dfa]
    /usr/sbin/mysqld[0x91d4a2]
    /usr/sbin/mysqld[0x928fd8]
    /usr/sbin/mysqld[0x928acf]
    /usr/sbin/mysqld[0x885508]
    /usr/sbin/mysqld[0x8d214b]
    /usr/sbin/mysqld[0x8d1c9a][/B]
     
    #5 Carmstrongclark, Jun 12, 2016
    Last edited by a moderator: Jun 12, 2016
  6. ssfred

    ssfred Well-Known Member

    Joined:
    Jan 6, 2012
    Messages:
    62
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello :)

    Check whether OOM killer terminates the MySQL server. You can check it using the following command

    # egrep -i "oom|kill|mysql" /var/log/messages
     
  7. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Hello ssfred,

    Thank you for your respones. When I enter the suggested command I get the following:

    egrep: /var/log/messages: Permission denied

    Have logged into Putty correctly but recieve this message when attempting most commands. :S
     
  8. twhiting9275

    twhiting9275 Well-Known Member

    Joined:
    Sep 26, 2002
    Messages:
    538
    Likes Received:
    15
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    You need to be doing that as root. If you don't have root access, then that's why you're not seeing permissions.
     
  9. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Oh duh - so I ran the command you suggested. I think most of it was killed but the last part was the following:

    Jun 14 05:29:17 s45-40-136-69 PAM-hulk[3752]: Brute force detection active: 400 Unable to connect to database backend: Failed to connect to mysql db: cphulkd: .
    Jun 14 05:29:27 s45-40-136-69 PAM-hulk[3806]: Brute force detection active: 400 Unable to connect to database backend: Failed to connect to mysql db: cphulkd: .

    So based on that I'd imagine it wasn't successful.
     
  10. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    I have tried to locate Mysql files but it just states no such directory. When I try to start MySql I get "Starting MySql........................." without it ever processing. Weird that MySQL could have just vanished or moved.
     
  11. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Update:

    I thought I would try and reset MySql again to see how it reacts after the command. At least it now recognises theres an issue and it's not running.
    Service Error
    (XID yky6ct) The “mysql” service failed to start.

    Startup Log
    Starting MySQL..................................................................................................... ERROR! The server quit without updating PID file (/var/lib/mysql/s45-40-136-69.secureserver.net.pid).

    Log Messages
    160614 06:18:36 mysqld_safe mysqld from pid file /var/lib/mysql/s45-40-136-69.secureserver.net.pid ended
    2016-06-14 06:18:36 14882 [Note] /usr/sbin/mysqld: Shutdown complete
     
  12. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    123
    Likes Received:
    36
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    What errors (if any) are you seeing in your /var/lib/mysql/HOSTNAME.err file ?
     
  13. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Hi Rpww - I cant access the .err file. All I get is No such file or directory.

    When I searched to find all socket files - it would appear that my.sql.sock doesn't exist at all. :S [Have uploaded to show example]



     

    Attached Files:

  14. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    123
    Likes Received:
    36
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    You did change HOSTNAME to reflect the actual hostname of your server ?



    Please see this cPanel Documentation page for more information:
     
  15. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Sorry yes, I had been doing so but just realised I was missing a dash. Aplogies that you have to put up with me ha

    [root@s45-40-136-69 ~]# /var/lib/mysql/s45-40-136-69.secureserver.net.err
    -bash: /var/lib/mysql/s45-40-136-69.secureserver.net.err: Text file busy
     
  16. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    123
    Likes Received:
    36
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    You will probably want to view the file using the
    Code:
    # cat <filename> | less
    command
     
  17. Carmstrongclark

    Joined:
    Jun 10, 2016
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Bristol, United Kingon
    cPanel Access Level:
    Website Owner
    Ok great :) have done that. The results have been uploaded as a file. Thanks for that
     

    Attached Files:

  18. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    123
    Likes Received:
    36
    Trophy Points:
    28
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    After looking over this thread from your first report, and because we can see no obvious errors in the err file other than the fact that the mysqld didn't shut down cleanly the previous time, I am beginning to wonder if your problem is memory and/or file capacity (or rather, a lack of it ).

    Rolling back your sites and their databases might have just given you the additional room for the daemon to have worked briefly until more was written to the table, and possibly more files added to the site ?

    I think it might be useful for you to check that you have sufficient memory and/or space left on your system, especially on the /tmp folder or file system.

    Perhaps some sql guru can jump in here and see something that we have missed.

    Or even better, and probably considerably faster - open a support ticket with cPanel and let the experts take the strain o_O
     
    #18 rpvw, Jun 15, 2016
    Last edited: Jun 15, 2016
Loading...

Share This Page