Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

neomas

Registered
Apr 4, 2008
4
0
51
I don't know how to solve error

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

when i restart SQL Server (MySQL) on WHM
it's error

/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
mysql has failed, please contact the sysadmin (result was "mysql has failed").
 

Stephanie_R

Active Member
Mar 1, 2004
36
0
156
Sounds like something ate your symlink in /tmp

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

restart MySQL
 

neomas

Registered
Apr 4, 2008
4
0
51
I try to solved and fixed everything but still same.
:mad: I don't know how to solve about this problem.

pls. help me.
 

rpmws

Well-Known Member
Aug 14, 2001
1,822
9
318
back woods of NC, USA
I try to solved and fixed everything but still same.
:mad: I don't know how to solve about this problem.

pls. help me.
/scripts/restartsrv_mysql

if that doesn't work.

/scripts/mysqlup --force
 

romyloice

Registered
Apr 6, 2007
1
0
151
Bandung
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock

Same with me..

Mine :
WHM 11.15.0 cPanel 11.18.5-R24173
CENTOS Enterprise 5 x86_64 on standard - WHM X v3.1.0

/scripts/mysqlup --force
completed, but still have the same problem..
error message :
/usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists! mysql has failed, please contact the sysadmin (result was "Warning, no valid mysql.sock file found.mysql has failed").

checking /var/lib/mysql/mysql.sock does not exist.. :(

/scripts/mysqlconnectioncheck gives nothing..

Any clue ??
 
Last edited:

shital

Member
May 28, 2007
11
0
151
Hello,

Did you check the partition size on file system?? I mean may be /var is 100% full on server. Thats the reason mysql could not be started on server.

MySQL sock file not found
====================

= killall -9 mysqld
= service mysql stop
=cp var/lib/mysql/mysql.sock var/lib/mysql/mysql.sock_backup
= rm -f /var/lib/mysql/mysql.sock
= service mysql start
= ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
= /scripts/restartsrv mysql

Hope this will help you to resolve this issue as it helps me always :)

Shital
 

Bigwebmaster

Active Member
Dec 3, 2003
32
9
158
Try and open up your /etc/my.cnf file and see if you can find this:

Code:
[mysql.server]
user=mysql
basedir=/var/lib
Comment out the basedir variable so that it looks like this:

Code:
[mysql.server]
user=mysql
#basedir=/var/lib
Then try and restart mysql and see if that fixes it.
 

FourMat

Active Member
Jun 10, 2004
36
0
156
Comment out the basedir variable so that it looks like this:

Code:
[mysql.server]
user=mysql
#basedir=/var/lib
Then try and restart mysql and see if that fixes it.
Can someone tell me why this works?

I just made that change and now my mysql server is up and running after having the same problem as the original poster.....
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,581
56
308
cPanel Access Level
Root Administrator
Can someone tell me why this works?

I just made that change and now my mysql server is up and running after having the same problem as the original poster.....
The basedir directive instructs MySQL where to find everything it needs to function: binaries, libraries, data, etc. Hence by stipulating basedir=/var/lib, MySQL will search /var/lib for everything needed to perform its functions.

For typical installs via RPM, this directive is not needed and should not be used. For a more exhaustive description of this directive, please consult the MySQL manual.
 

FourMat

Active Member
Jun 10, 2004
36
0
156
Thanks for the info. I am trying to get this newly configured server up and running and was a little surprised to find that the mysql server wasn't working out of the box.

Thanks for the help!
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,581
56
308
cPanel Access Level
Root Administrator
Thanks for the info. I am trying to get this newly configured server up and running and was a little surprised to find that the mysql server wasn't working out of the box.

Thanks for the help!
Nothing in cPanel adds the basedir directive to /etc/my.cnf, which means it was added by something/someone outside cPanel's functions.
 

bhstudios

Member
Jul 26, 2007
18
0
51
Chile - SCL
Can someone tell me why this works?

I just made that change and now my mysql server is up and running after having the same problem as the original poster.....
Excellent contribution, i was totally lost tried evrything, only think that worked was this, thanks FourMat :D
 

samomania21

Registered
Jun 15, 2010
1
0
51
Restart the mysql server

sometimes, during load up the server might not start. the following worked for me. RESTARTING THE MYSQL SERVER

/etc/init.d/mysqld restart