Drupal 4.6.4
Operating System: Linux
Apache Version: 1.3.34 (Unix)
PHP Version: 4.4.1
Mysql Version: 4.1.14-standard

Warning: I'm not a developer or webserver expert, just an administrator trying to get a Drupal site live and working, so I may need slightly more detailed help than some folks. I'm not dumb, however, so I'll do my best to understand if someone can point me in the right direction.

We've had our new Drupal site under development on a VPS for a couple of months now, slowly getting content transferred from the old one and modules installed, testing all along the way. A short while ago, we experienced a sudden MySQL error and subsequent server problems that caused our host to move our stuff to a new server, configured in the same way that the previous one had been. After tweaking, we thought things were okay, but then the same MySQL error started re-occuring:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in /home/thetown/public_html/includes/database.mysql.inc on line 31
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

We got the host to check it with this result:

It looks as though the wrong mysql was installed with your
version of apache and php. Everything was fine until apache reset,
then it broke. This appears to have been a problem in our original
setup, but we've recompiled everything, and installed it again, so it
is currently up and running.

Then the error came back next day:

We just restarted mysql, and everything appears to be up and
running fine again. We're not 100% sure what caused this yet, but we
are looking into it right now.

And again:

I've started up MySQL on your server again, so everything is
currently up and running. But, you're right, something does seem to
be triggering this regularly. We are going to have an admin take a
more in depth look into your system today and see if we can pin point
exactly what it is that's causing MySQL to go down.

followed by:

It would appear that there is something running on your system that is restarting you mysql server around 4:50 each morning EST. For the last 2 days that something did not make sure that mysql started back up correctly, this is why you get the error below. That I am aware of we have not installed anything that would do this. You may want to check with your programmers and see if they have anything that might be doing this.

Now since I don't have any 'programmers' and the only thing running MySQL or anything else on there is Drupal, I thought I'd better ask if anyone here knows what might be triggering it.

There are no cron jobs set (I tried to set one up but it wasn't working - I obviously did it wrong - so I removed it again; I use cPanel for that sort of thing.)

If anyone can help, I'd really really appreciate it! If there's something that needs reconfiguring on the server side, I can ask the host to do it if I know what it is. Or, if it's something that needs fixing in my Drupal installation, I can do that myself. Obviously, I can't go live with a site that needs MySQL to be reset every day.

Thanks in advance,

Phoebe
--
Visit The Town
www.the-town.org
meet ~ discuss ~ connect

Comments

John Rodat’s picture

Phoebe & colleagues

We've had what appears to be the same problem three times in the past couple of weeks. Except for the addresses and file names, the error message was the same.

In each case, the problem didn't last very long, perhaps only a few minutes and then the site returned to normal functioning without any intervention.

We're using Drupal 4.5 and MySQL 4.0.25, Apache 1.3.34 (Unix) and Linux.

A major difference is that our site has been running since January of 2005 without this problem, or at least my being aware of it.

We are running chron jobs.

My knowledge is probably a bit less than yours so I'm baffled and not a little concerned.

benofsky’s picture

Did you install through Fantastico, if so go for a manual clean install or it'll all end up BIG MESS!

phoebe-1’s picture

I will need to check how this was installed originally, but can you explain why it would be a problem?

There is a lot of configuration in there and I really don't want to lose it all with a new installation if there's a way to avoid it at all.

Phoebe
--
Visit The Town
meet ~ discuss ~ connect
www.the-town.org

benofsky’s picture

Fantastico comes with quite alot of web packages, I started off my drupal install from fantastico, doing so makes it difficult to change database settings and I got lots of errors until I moved to a manual install. I just guessed because that's the sort of error I got when I had a fantastico Install. In the end I just created a fresh install but in settings.php I linked to the old MySQL database, I see you are using cPanel (usually fantastico comes installed with that)! I'd just stay away from fantastico!
Ben
Benofsky Park.com

benofsky’s picture

Thought I should mention that fantastico is just a small web application for installing things like wordpress, form creators, drupal and other CMS's
Ben
Benofsky Park.com

benofsky’s picture

I'm guessing that your using drupal for blogs, If your drupal install is being used just for blogs I reccomend switching to wordpress (which Is like a diluted version of drupal)!
Ben
Benofsky Park.com

phoebe-1’s picture

When we were testing Drupal originally, we did use a Fantastico install. However, I'm not sure if this particular installation was done that way as I didn't do it, the webhost did.

I do know that I manually upgraded it, not long after it was set up, from the installed 4.6.3 to 4.6.4 using the download from here and its instructions.

Having said that, everything was fine from that time back in early December until about two weeks ago, when the MySQL error suddenly showed up. I can't imagine why it would suddenly occur now rather than happening some time ago when the upgrade was done.

Incidentally, the Drupal site in development is here: http://216.194.115.14/

The site in my sig line is our existing site which we are migrating to Drupal.

Phoebe
--
Visit The Town
meet ~ discuss ~ connect
www.the-town.org

benofsky’s picture

What I find makes most of my SQL errors is when the cache table gets really big (5-10MB), the site dosn't work, in phpmyadmin just empty the cache table (don't delete it). You could try that.
Ben
Benofsky Park.com

phoebe-1’s picture

I manually upgraded the Drupal installation on Saturday morning, in the hopes it might make a difference. I thought it had until this morning when the error returned right on schedule.

It seems that something is running every morning Monday-Friday and when it hits this line in the file database.mysql.inc

$connection = mysql_connect($url['host'], $url['user'], $url['pass'], TRUE) or die(mysql_error());

it causes MySQL to stop and we then have to ssh in and restart MySQL. I'm not a programmer so unfortunately I don't know what that means to be able to work out what could be wrong.

There's nothing that I've put in that should be running periodically like this, and the webhost says they haven't loaded anything, so I don't know where it's coming from.

Does anyone know if there's anything in Drupal that might be trying to run daily like that? As I said before there are no cron jobs set for our installation yet.

And if the answer is that it's something to do with our server configuration, then can anyone point me in the right direction to look at it with the webhosts? They're stumped and so am I.

Phoebe
--
Visit The Town
meet ~ discuss ~ connect
www.the-town.org

Heine’s picture

The regularity is weird; my first guess would be a server cronjob that removes temporary files (eg *.sock) every morning.

Do you have access to MySQL's error log? If necessary start mysql with --log-error, which will make the default error log: The mysql-data-directory/your_hostname.err

If the error log doesn't provide any insights, it might be prudent to generate a query log by starting MySQL with --log .

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

storm80y’s picture

Seems to fix my site, although it's not Drupal. If I change it back to localhost it fails again.

Heine’s picture

If you use localhost MySQL (drivers) attempt to use a socket file (or named pipe), because it's much faster than the TCP/IP stack (although 127.0.0.1 should bypass some layers). Using 127.0.0.1 doesn't use the socket file; that's why it solves your particular problem.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

davidmcm’s picture

I'm getting the same kind of error message:

ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I can't decipher the resolution in the above comments and replies.

-- David

Heine’s picture

There was no resolution.

--
The Manual | Troubleshooting FAQ | Tips for posting | Make Backups! | Consider creating a Test site.

ralph_lnx’s picture

My solution for your problem is:



I have Drupal mounting in Linux Operating System (Debian Stable Sarge 3.1).


Copy yours MySQL configuration files to a secure folder.


~# cp /etc/mysql [secure_folder]/mysql_on_etc

~# cp /var/lib/mysql [secure_folder]/mysql_on_var_lib


Then, proceed to uninstall MySQL and remove all files of the old installation.


~#dpkg -l |grep 'mysql'


This command show in the console all installed packages with the word "mysql" in the name.

The drupal only use mysql-server, mysql-common and php5-mysql.
For uninstall use apt-get and this is a way for no have problem with dependencies packages.


~#apt-get remove mysql-server


This command remove mysql-server and her dependencies, included mysql-common.


~#apt-get remove php5-mysql


Now clean the files of old installation using dpkg -P or dpkg --purge.


~#dpkg -P mysql-common

~#dpkg -P mysql-server


If have a problem remove the files manually.


~#rm -r /var/lib/mysql

~#rm -r /etc/mysql


Then install the MySQL packages, and later copy the configuration an database files from your secure folder to his place.


~# apt-get install mysql-server php5-mysql

~# cp [secure_folder]/mysql_on_etc /etc/mysql

~# cp [secure_folder]/mysql_on_var_lib /var/lib/mysql


I do that and can resolve my problem.

Sorry if my English no is so good. I'm cuban and my language is the spanish.

Milkrow’s picture

I had this issue with a fresh install of 6.19. I tried the change of "localhost" to "127.0.0.1" in the db_url line of the settings.php file, but to no avail, so I simply changed it back and tried again and the connection was made correctly. I'm not sure if the faulty connection through that socket is going to reoccur (like the other accounts in this string of a recurring event that broke the socket connection)...but I'll keep an eye on it. I checked and it seems like MySql is version 5???, and PHP is 5.2.12 on LInux shared hosting.

I've not worked with this host before, and I had a feeling it might be a crapshoot.

Should I verify the exact version of MySql if the problem persists? Or is there another issue? Permissions? I'm not a server config wiz, but have some experience with Drupal...so I'll do my best to understand stuff, but I don't know how to do command line stuff. Thanks!