Re: losing mysql connection during cron job

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Thanks for the suggestion.  I am currently successfully working around
> this error by another method, although your suggestion is probably better.
> 
> The reason I posted this problem, though, is that I want to understand
> *why* I'm getting the "Lost connection to MySQL server during query" error.
> 
> If anyone has had a similar experience using cron jobs or sleep() I'd
> love to hear from you.

- database is restarted for whatever reason (log rotation, dba does an
upgrade etc etc).
- mysql has a 'wait_timeout' setting which could trigger it

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_wait_timeout

You need to do a
mysql_close();
mysql_connect(...)

before mysql_query works again - otherwise mysql_connect will just
return the same resource id (or I guess just use the 'new_connection'
flag for mysql_connect and skip the mysql_close()).

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux