Solved

MySQL server has gone away...

Posted on 2004-09-20
2
448 Views
Last Modified: 2006-11-17
I have written a Perl script that accesses a MySQL database repeatedly. After a few hundred selections & insertions into the database, subsequent selections are always answered with the following error message:

DBD::mysql::db selectrow_hashref failed: MySQL server has gone away at Metabase.pm line 67.

However,  Line 67 is just, and it worked perfect for the first few hundred database queries.
return $obj->{dbh}->selectrow_hashref($q2);

Any idea of what could be going on?  Thanks.
0
Comment
Question by:bobwood2000
2 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 400 total points
ID: 12109453
Perhaps your database connection is timing out. My initial suggestion would be to add more error reporting. Above your selectrow_hashref sstatement there is probably a prepare and execute statement. You could add something similar to the following:

my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr";

and then
if $obj->{dbh}->selectrow_hashref($q2) {
   return $obj->{dbh}->selectrow_hashref($q2
}else
{
   die "Can't execute statement: $DBI::errstr";
}
 
0
 

Author Comment

by:bobwood2000
ID: 12109663
Thanks for the help.

Rather than timing out, it seems I was trying to insert too much data into a single column. I was able to change the limit on the amount of data that may be inserted into a single column by adding "set-variable = max_allowed_packet=4M" (no quotes) to my.ini/my.cnf file in the [mysqld] block (and then restarting mysqld).

 
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question