Solved

MySQL server has gone away...

Posted on 2004-09-20
2
440 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now