[Case 105565] recreate /tmp/mysql.sock on mysql restart

simonas

Well-Known Member
Apr 21, 2013
141
0
16
Lithuania
cPanel Access Level
Root Administrator
Hello everybody,

With the latest update (Cpanel version: 11.44.0 (build 17)) one of my server's began having problem - system could not connect to the mysql.

Code:
Cron <[email protected]> /usr/bin/test -x /usr/local/cpanel/scripts/update_db_cache && /usr/local/cpanel/scripts/update_db_cache

Error while connecting to MySQL: Cpanel::DBI::Mysql connect('','root',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at /usr/local/cpanel/Cpanel/Mysql.pm line 140
Also MODSEC:

Code:
/etc/cron.hourly/modsecparse.pl:

DBI connect('modsec:localhost','modsec',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at /etc/cron.hourly/modsecparse.pl line 20
Unable to connect to mysql database at /etc/cron.hourly/modsecparse.pl line 20.
After investigating with the help of Cpanel, we found that
MySQL no longer automatically re-creates symlink if it's not present.
And openened inquiry (#105565).

Quick solution would be add to you /etc/my.cnf:
[client]
socket=/var/lib/mysql/mysql.sock
Or create symlink. Mods, please update this thread. Thanks.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello :)

Internal case number 105565 is open to inquire if /tmp/mysql.sock should be recreated after MySQL restarts. I will update this thread with more information as it becomes available. In the meantime, manually creating the symbolic link is a valid workaround if it does not exist:

Code:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Thank you.
 

jayrex

Registered
Jul 6, 2014
1
0
1
cPanel Access Level
Root Administrator
Hello :)

Internal case number 105565 is open to inquire if /tmp/mysql.sock should be recreated after MySQL restarts. I will update this thread with more information as it becomes available. In the meantime, manually creating the symbolic link is a valid workaround if it does not exist:

Code:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Thank you.
I believe I have the same type of problem:

Error while connecting to MySQL: Cpanel::DBI::Mysql connect('','root',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at /usr/local/cpanel/Cpanel/Mysql.pm line 140 Error while connecting to MySQL: Cpanel::DBI::Mysql connect('','root',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at /usr/local/cpanel/Cpanel/Mysql.pm line 140 ...caught

Could someone let me know if this can be fixed?

I won't be able to fix this myself as I'm not technical, but it looks like an automatic update created this error, will cPanel bring out another update to fix this error?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Did you try running the command referenced in my previous post?

Thank you.