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

Jun 10, 2016
10
0
1
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.
 
Last edited by a moderator:

Infopro

Well-Known Member
May 20, 2003
17,113
513
613
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?
 
Jun 10, 2016
10
0
1
Bristol, United Kingon
cPanel Access Level
Website Owner
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?

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.
 
Jun 10, 2016
10
0
1
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]
 
Last edited by a moderator:

ssfred

Well-Known Member
Jan 6, 2012
65
4
58
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
 
Jun 10, 2016
10
0
1
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.
 
Jun 10, 2016
10
0
1
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
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
458
113
UK
cPanel Access Level
Root Administrator
What errors (if any) are you seeing in your /var/lib/mysql/HOSTNAME.err file ?
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
458
113
UK
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:
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
458
113
UK
cPanel Access Level
Root Administrator
You will probably want to view the file using the
Code:
# cat <filename> | less
command
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
458
113
UK
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
 
Last edited: