Forums / General Questions / mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

Started by liderbug on 9 Dec 2014, 2:36 PM · Views: 6,630

Results 1 to 5 of 5
9 Dec 2014, 2:36 PM
#1
liderbug avatar

liderbug

Zen Follower

Join Date:
Jul 2009
Posts:
104
Plugin Contributions:
0

mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

I just recently upgraded to 1.5.3 and now I'm getting a lot of these logs. 90% of the time everything seems to work then "Sorry the site is down for Maint.".

[09-Dec-2014 07:55:03 America/New_York] PHP Warning: mysqli_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in includes/classes/db/mysql/query_factory.php on line 62

 60     while (!isset($this->link) || ($this->link == FALSE && $connectionRetry !=0) )
 61     {
 62       $this->link = mysqli_connect($zf_host, $zf_user, $zf_password);
 63       $connectionRetry--;
 64     }

Thoughts.
Thanks

9 Dec 2014, 5:16 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

... through socket '/var/lib/mysql/mysql.sock' (2) in includes/classes/db/mysql/query_factory.php on line 62 ...
This indicates your website has PHP configured to connect to MySQL using the specified UNIX socket. Error number 2 usually indicates the socket does not exist (or PHP does not have access to the socket).

Would recommend contacting your hosting provider to resolve the issue.

Alternatively if you know the settings required by your hosting provider to connect to MySQL (such as host / port -- or -- host / socket) and have access to php.ini you can update the MySQL related section in php.ini (to use the correct port or socket by default).

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

12 Dec 2014, 4:03 PM
#3
liderbug avatar

liderbug

Zen Follower

Join Date:
Jul 2009
Posts:
104
Plugin Contributions:
0

Re: mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

From my hosting company:

The interesting thing is, it's the only database table this is happening to, none of your other ones have shown the same problem in the logs.

However there are times when I run mysqlcheck I get Failed to Connect. And I have a daily script
for db in "show databases (returns 10)" (pseudo code)
do
mysqlcheck db
done

I get several lines on different DBs: "warning 3 clients are using or haven't closed the table properly"
even on a db/table that is not in use. It makes me wonder if another user/hacker is over connecting. My problem with checking for that is all users are "jailed" so I can't do top,ps,who,etc. Which doesn't mean some 14 yo russian kid isn't scanning my DB's for data or that another user has a webpage w DB that's hammering the L out of things. Also when I pull up a given webpage, uses mysql, and get "Woops. Can't connect". So I reload the page and it works.

Anything/argument/direction I can give my hosting company?

Thanks
cal

12 Dec 2014, 4:31 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

liderbug:

From my hosting company:

The interesting thing is, it's the only database table this is happening to, none of your other ones have shown the same problem in the logs.

You must have given your hosting company different information than you have given us. Either that, or they are feeding you BS, because the log entry provided doesn't indicate which table is being accessed, therefore they can't possibly say its the only one.

Besides that, the error log provided clearly show that it is an issue connecting to the database and until it an do this it has no way of accessing ANY of the tables.

liderbug:

However there are times when I run mysqlcheck I get Failed to Connect. And I have a daily script
for db in "show databases (returns 10)" (pseudo code)
do
mysqlcheck db
done

Who is "I" in this case? You or someone from the hosting company?

liderbug:

I get several lines on different DBs: "warning 3 clients are using or haven't closed the table properly"
even on a db/table that is not in use.

Nothing particularly unusual here. There are many possible causes. eg: Client gone away, code not correctly closing the tables after use, Server overloaded.

liderbug:

It makes me wonder if another user/hacker is over connecting.

Do you have a reason for thinking this? What?

liderbug:

My problem with checking for that is all users are "jailed" so I can't do top,ps,who,etc.

Nothing unusual here.

liderbug:

Which doesn't mean some 14 yo russian kid isn't scanning my DB's for data

It does mean that if the server doesn't allow remote access, and MANY don't. Thanks to a Nasty Miscrosoft bug many years a ago many hosts consider this as too much of a security risk (something that I don't agree with, its more secure than FTP, which all hosts seem to allow without a seconf thought).

liderbug:

or that another user has a webpage w DB that's hammering the L out of things.

Or perhaps even a search engine (if the host isn't up to handling the traffic).

liderbug:

Also when I pull up a given webpage, uses mysql, and get "Woops. Can't connect". So I reload the page and it works.

Sound to me like the MySQL server can't handle what is being asked of it.

liderbug:

Anything/argument/direction I can give my hosting company?

Thanks
cal

It isn't for you (or me) to give a hosting company any direction or argument. They will have logs to indicate these server errors and it is really up to them to find the cause and solution. All you can really do is try to keep track of when it occurs and keep submitting fault reports.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

13 Dec 2014, 3:48 AM
#5
liderbug avatar

liderbug

Zen Follower

Join Date:
Jul 2009
Posts:
104
Plugin Contributions:
0

Re: mysqli_connect fails through socket '/var/lib/mysql/mysql.sock'

First... WOW. Quite the reply. thanks

RodG:

You must have given your hosting company different information than you have given us. Either that, or they are feeding you BS, because the log entry provided doesn't indicate which table is being accessed, therefore they can't possibly say its the only one.

I've given them several things - I started with the connect-fail entry and have through several email tried to explain things I've tried - to help find the problem.

Besides that, the error log provided clearly show that it is an issue connecting to the database and until it an do this it has no way of accessing ANY of the tables.

Who is "I" in this case? You or someone from the hosting company?

I = me

Nothing particularly unusual here. There are many possible causes. eg: Client gone away, code not correctly closing the tables after use, Server overloaded.

Well one thing - one of the tables (pizza) complains that a table wasn't closed. But "pizza" is a test DB and is only used by me from the command line and the last time .... was ... 6 months ago???

Do you have a reason for thinking this? What?

See the above comment

Nothing unusual here.

It does mean that if the server doesn't allow remote access, and MANY don't. Thanks to a Nasty Miscrosoft bug many years a ago many hosts consider this as too much of a security risk (something that I don't agree with, its more secure than FTP, which all hosts seem to allow without a seconf thought).

I have remote access. echo "select...." | mysql -u me ..... -h remoteserver.com

Or perhaps even a search engine (if the host isn't up to handling the traffic).

Hmmmm hmmmmmmmmm have to look in to that

Sound to me like the MySQL server can't handle what is being asked of it.

My thoughs. I can't see the logs (if any) - though I could write a script, mysqlcheck, log not-closed. Then check against Apache logs. I've got a bot scan and a error at the same time???

It isn't for you (or me) to give a hosting company any direction or argument. They will have logs to indicate these server errors and it is really up to them to find the cause and solution. All you can really do is try to keep track of when it occurs and keep submitting fault reports.

Hmmm I hear you but... I spent 12 years as 4th level support, 1st level had a 3 ring binder and got paid $12/hr. 2d level had training and were pretty smart $x2. 3d didn't exist. Then there was my group, had acccess to code & programmers and were expected to track and solve everything right down to telling the programmers what the code error was. I remember one of the last problems "2d: Box E47 won't process, we've tried everything - even reboot." me: "hmmm, click, type, click, check Do a 'df'" 2d: "S***!!" One of the disks had filled, 1st missed it, 2d missed it. I'm not sure where my hosting support falls, really sharp on some things, had never heard of COPS. And DB problems they had off.

Cheers
RodG

Just checked the apache logs. Looks like 50% of the logs entries with nddbc.html have the letters "bot" in the line. The IP with the most, 54.224.86.121, Amazon Tech. I also noticed that when I upgraded zen-cart robots.txt got lost, not put back. Will now sit back and watch.

Thanks again for the help.