Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL server has gone away...

Posted on 2004-09-20
2
Medium Priority
?
453 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 1200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

927 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