| Author |
Message |
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Tue Apr 04, 2006 9:57 pm Post subject: Lost connection to MySQL server during query |
|
|
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()); |
|
| Back to top |
|
cherring
Joined: 17 Feb 2006
Posts: 83
|
| Posted: Tue Apr 04, 2006 10:38 pm Post subject: Re: Lost connection to MySQL server during query |
|
|
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. |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 05, 2006 7:27 am Post subject: |
|
|
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"); |
|
| Back to top |
|
cherring
Joined: 17 Feb 2006
Posts: 83
|
| Posted: Wed Apr 05, 2006 7:45 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 05, 2006 10:23 am Post subject: |
|
|
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... |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 05, 2006 1:06 pm Post subject: It was worth a try |
|
|
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? |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 05, 2006 8:36 pm Post subject: |
|
|
| 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... |
|
| Back to top |
|
cherring
Joined: 17 Feb 2006
Posts: 83
|
| Posted: Wed Apr 05, 2006 8:57 pm Post subject: |
|
|
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) |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 05, 2006 10:18 pm Post subject: |
|
|
| Great thank you!! Everthing is still working great!!! |
|
| Back to top |
|
cherring
Joined: 17 Feb 2006
Posts: 83
|
| Posted: Thu Apr 06, 2006 1:08 am Post subject: |
|
|
| Glad to be of help. I'm normally seeking help so it's nice to help someone. I wish you all the best. :) |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Fri Apr 07, 2006 4:04 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Fri Apr 07, 2006 5:19 pm Post subject: |
|
|
| Even the register_globals does nothing for me. Got the error again any suggestions? |
|
| Back to top |
|
Beek
Joined: 30 Mar 2005
Posts: 10
|
| Posted: Fri Apr 07, 2006 9:29 pm Post subject: |
|
|
| http://dev.mysql.com/doc/refman/5.0/en/gone-away.html |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 12, 2006 5:34 pm Post subject: vio_error: Got error 11 during read |
|
|
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) |
|
| Back to top |
|
fifo
Joined: 29 Sep 2005
Posts: 68
Location: Miami, Florida
|
| Posted: Wed Apr 12, 2006 8:44 pm Post subject: I enable mysql.trace_mode on php.ini |
|
|
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? |
|
| Back to top |
|
| |