Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Apr 04, 2006 10:57 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
I have this intermitent problem...

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in /var/www/localhost/htdocs/xyz.php on line 32
Can not connect to the database. Lost connection to MySQL server during query


I can get rid of this error by setting register_globals on in my php.ini but I want to know if there is a real fix without doing this.

Here is a sample of what I am doing in my xyz.php file to connect

define('LOC','LOC');
define('USER', 'USER');
define('PASS', 'PASS');
define('DB', 'DB');

mysql_connect(LOC,USER,PASS)
or die("Can not connect to the database. " . mysql_error());


mysql_select_db(DB)
or die("Can not select database. " . mysql_error());


Top
   
PostPosted: Tue Apr 04, 2006 11:38 pm 
Offline
Senior Member

Joined: Fri Feb 17, 2006 9:47 pm
Posts: 91
fifo wrote:
define('LOC','LOC');
define('USER', 'USER');
define('PASS', 'PASS');
define('DB', 'DB');

mysql_connect(LOC,USER,PASS)
or die("Can not connect to the database. " . mysql_error());


mysql_select_db(DB)
or die("Can not select database. " . mysql_error());


I normally have something like:

$LOC = "LOC";
$USER = "USER";
$PASS = "PASS";
$DB = "DB";

$link = mysql_connect($LOC, $USER, $PASS)
or die("Can't Connect");

mysql_select_db($DB, $link) or die("Can't Connect");

That kind of setup has always worked for me.


Top
   
 Post subject:
PostPosted: Wed Apr 05, 2006 8:27 am 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
It seems to be the same thing.

I't does work however about 25 % of the times I am accessing the site I get that error. But the other 75% it works fine...

Let me check if I have the $link variable in there I might and I will get back as soon as I have access to my files..

mysql_select_db($DB, $link) or die("Can't Connect");


Top
   
 Post subject:
PostPosted: Wed Apr 05, 2006 8:45 am 
Offline
Senior Member

Joined: Fri Feb 17, 2006 9:47 pm
Posts: 91
Yes I realise that they are basically the same, I just was thinking that having
Code:
$link = mysql_connect($LOC, $USER, $PASS)
rather than just
Code:
mysql_connect($LOC, $USER, $PASS)
and also having
Code:
mysql_select_db($DB, $link)
helps because it explicitly uses that link to connect that way so you are less likely to lose your connection. I'm not sure if it actually makes a difference as I have never had any problems, perhaps it is a problem with your mysql server, this however is just speculation on my part but maybe you should check your apache and MySQL logs.


Top
   
 Post subject:
PostPosted: Wed Apr 05, 2006 11:23 am 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
ok that sounds like a reasonable explanation. I dont think its my MySql installation because I just upgraded to the latest and greatest and I a still getting the error. Its kind of wierd ...

Either way thanks for the help im going to try that out and let you know how it goes...


Top
   
 Post subject: It was worth a try
PostPosted: Wed Apr 05, 2006 2:06 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
Ok so I tried it out but I am still getting those errors every once in a while. I will however leave my connection as you said because it makes more scence than what I was doing.

Can I pick your brain for any more Ideas?


Top
   
 Post subject:
PostPosted: Wed Apr 05, 2006 9:36 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
I looked in my /etc/php directory and I still had some files from my old php4 installation apache2-php4 or something of that sort. I removed that and rebooted and well it hasnt done it since. Ist there an explanation for this? where the configurations fighting against each other? Well its probalbly too soon to say its working but I have been trying to crash it and it hasnt so far.... lets just wait and see...


Top
   
 Post subject:
PostPosted: Wed Apr 05, 2006 9:57 pm 
Offline
Senior Member

Joined: Fri Feb 17, 2006 9:47 pm
Posts: 91
I'd say it's possible that were conflicts arising from having multiple configuration type things present but I couldn't be sure, getting rid of stuff you don't need anymore can't be a bad thing though I would say. If you have any other problems then I'd be happy to help, if I can.

Good Luck 8)


Top
   
 Post subject:
PostPosted: Wed Apr 05, 2006 11:18 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
Great thank you!! Everthing is still working great!!!


Top
   
 Post subject:
PostPosted: Thu Apr 06, 2006 2:08 am 
Offline
Senior Member

Joined: Fri Feb 17, 2006 9:47 pm
Posts: 91
Glad to be of help. I'm normally seeking help so it's nice to help someone. I wish you all the best. :)


Top
   
 Post subject:
PostPosted: Fri Apr 07, 2006 5:04 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
Ok I guess that really didnt fix the probelm. It happened again today and it brought the server down as it has done before in the past. Any other suggestiong? in the mean time I will try to enable register_globals


Top
   
 Post subject:
PostPosted: Fri Apr 07, 2006 6:19 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
Even the register_globals does nothing for me. Got the error again any suggestions?


Top
   
 Post subject:
PostPosted: Fri Apr 07, 2006 10:29 pm 
Offline
Senior Newbie

Joined: Thu Mar 31, 2005 12:49 am
Posts: 10
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html


Top
   
PostPosted: Wed Apr 12, 2006 6:34 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
So I recompiled with the debug flag and now I can see the so called trace. Im not sure what to make of it but this seems to be where it is getting stuck. Something about a vio error? I dont see a stack trace like the one mentioned in the documentation as noted above. I have tried tweeking some of the timeout values but ended up putting them back as that did not help. Im going crazy with this. Funny thing is I have the exact code running on another server and it works fine... So I dont hink it has anything to do with the queries I am running... Either way I am open eyes and ears about this Im not sure what I should try next. Once I get this the server either hangs or crashes...


6384: | | | | | | | | exit: ptr: 0x8cc8178
T@16384: | | | | | | | <_mymalloc
T@16384: | | | | | | | >_myfree
T@16384: | | | | | | | | enter: ptr: 0x8cc18b0
T@16384: | | | | | | | <_myfree
T@16384: | | | | | | <_myrealloc
T@16384: | | | | | <mi_extra
T@16384: | | | | <close_thread_table
T@16384: | | | <close_thread_tables
T@16384: | | | >free_root
T@16384: | | | | enter: root: 0x8ccdfcc flags: 1
T@16384: | | | <free_root
T@16384: | | <dispatch_command
T@16384: | | >do_command
T@16384: | | | >vio_is_blocking
T@16384: | | | | exit: 0
T@16384: | | | <vio_is_blocking
T@16384: | | | >vio_read
T@16384: | | | | enter: sd=16, buf=0x8ccf388, size=4
T@16384: | | | | vio_error: Got error 11 during read
T@16384: | | | | exit: -1
T@16384: | | | <vio_read
T@16384: | | | info: vio_read returned -1, errno: 11
T@16384: | | | >thr_alarm
T@16384: | | | | enter: thread: T@16384 sec: 28800
T@16384: | | | | info: reschedule
T@131081: | >process_alarm
T@131081: | | info: sig: 14 active alarms: 1
T@131081: | <process_alarm
T@16384: | | | <thr_alarm
T@16384: | | | >vio_blocking
T@16384: | | | | enter: set_blocking_mode: 1 old_mode: 0
T@16384: | | | | exit: 0
T@16384: | | | <vio_blocking
T@16384: | | | >vio_read
T@16384: | | | | enter: sd=16, buf=0x8ccf388, size=4
>vio_read
T@16384: | | | | enter: sd=16, buf=0x8ccf388, size=4
T@16384: | | | | vio_error: Got error 11 during read
T@16384: | | | | exit: -1


mysqld.err doesnt say much at least nothing about an error:q!

InnoDB: !!!!!!!!!!!!!! UNIV_DEBUG switched on !!!!!!!!!!!!!!!
060412 18:22:28 InnoDB: Started; log sequence number 0 47123
/usr/sbin/mysqld: ready for connections.
Version: '4.1.14-debug-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 Gentoo Linux mysql-4.1.14-r1

mysql.err says nothing same for mysql.log and mysqld.log

this is what I get when I try to run status on mysqladmin

mysqladmin -i 5 -r status

Uptime: 1295 Threads: 2 Questions: 1987 Slow queries: 0 Opens: 134 Flush tables: 1 Open tables: 43 Queries per second avg: 1.534 Memory in use: 17001K Max memory used: 19577K
Uptime: 1300 Threads: 4 Questions: 2049 Slow queries: 0 Opens: 134 Flush tables: 1 Open tables: 43 Queries per second avg: 1.576 Memory in use: 17117K Max memory used: 19577K
Uptime: 1305 Threads: 2 Questions: 2115 Slow queries: 0 Opens: 134 Flush tables: 1 Open tables: 43 Queries per second avg: 1.621 Memory in use: 17001K Max memory used: 19577K
Uptime: 1310 Threads: 4 Questions: 2184 Slow queries: 0 Opens: 134 Flush tables: 1 Open tables: 43 Queries per second avg: 1.667 Memory in use: 17116K Max memory used: 19577K
Lost connection to MySQL server during query
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)


Top
   
PostPosted: Wed Apr 12, 2006 9:44 pm 
Offline
Senior Member

Joined: Thu Sep 29, 2005 9:52 pm
Posts: 79
Website: http://www.hectorg.net
Location: Miami, Florida
I enabled mysql.trace_mode in the php.ini file like so

mysql.trace_mode = On

and this is what I got on my page. Why would this be happening?

Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0

is this just the current queries on the page? thats what it seems like to me... Should they be closed once the page is shown?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group