shellie

Member
Nov 26, 2002
18
0
151
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:
 

ciphervendor

Well-Known Member
Aug 26, 2002
1,050
0
166
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:
 

bmcclure

Well-Known Member
Apr 12, 2003
191
0
241
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:
 

Pilgrim

Active Member
Apr 29, 2002
27
0
301
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:
 

fgauthier

Member
PartnerNOC
Feb 22, 2003
16
0
151
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:
 

bmcclure

Well-Known Member
Apr 12, 2003
191
0
241
Racine, WI
The only mysql.sock on my machine right now is /usr/local/lib/mysql.sock but that's actually [email protected] 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:
 

compunet2

Well-Known Member
Feb 21, 2003
309
0
166
Same problem here.... mysql.sock missing... It seems to disappear when I do a graceful reboot.

cPanel.net Support Ticket Number:
 
Last edited:

consolutions

Registered
Sep 10, 2003
2
0
151
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:
 

bmcclure

Well-Known Member
Apr 12, 2003
191
0
241
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:

Waiting for mysql to restart.... . . . . . . . . . . finished.

mysql status

root 4134 0.4 0.1 2140 1076 ? S 08:39 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/three.andhosting.com.pid


mysql started ok
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:

DBI connect('mysql:localhost','root',...) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/local/cpanel/Cpanel/Mysql.pm line 42 30 / unlimited
cPanel.net Support Ticket Number:
 

bmcclure

Well-Known Member
Apr 12, 2003
191
0
241
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:
 

compunet2

Well-Known Member
Feb 21, 2003
309
0
166
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:
 

bmcclure

Well-Known Member
Apr 12, 2003
191
0
241
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:
 

jsoren

Member
Jun 5, 2003
8
0
151
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.
 
Last edited:

cPanelNick

Administrator
Staff member
Mar 9, 2015
3,481
35
208
cPanel Access Level
DataCenter Provider
Originally posted by jsoren
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.
Make sure all the rpms got installed from the update.

/scripts/updatenow
/scripts/sysup
 

cass

Well-Known Member
Jul 17, 2002
349
0
166
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.
 

RedFutura

Well-Known Member
Jun 11, 2003
72
0
156
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.
 

richy

Well-Known Member
Jun 30, 2003
274
1
168
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:
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
 

SiteShack

Member
Aug 22, 2003
12
0
151
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.