Solved

MySQL server has gone away...

Posted on 2004-09-20
2
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

751 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