Solved

MySQL server has gone away...

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl search and replace 6 165
perl script to check whether folder contains any files 5 77
Perl DBI Transactions Using Custom Module 7 45
Perl Awk Need Help 3 109
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

21 Experts available now in Live!

Get 1:1 Help Now