apache mod perl dbi mysql : Premature end of script headers:

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I am posting this through groups.google.com in case anyone has the
same problem I had and, like me, searches like crazy all over the web
in vain.

I am working through the early examples in "MySQL and Perl for the

The sample script 'intro7.pl' runs fine from the command line but
gives me the error Premature end of script headers: in my browser.  I
try all advice to no avail.  I try chmod 755 intro7.pl, etc...

Then I find the great advice to check my server error log, which in my
case is located at:

/var/log/apache2/error_log (I found this location through my

where I see: Can't connect to local MySQL server through socket

Luckily, this is a frustrating problem I have dealt with.  My rpm
installed version of MySQL insists on using this location for the
socket file.  I thought I had fixed this, but apparently not in the
case when DBI tries to access it for some reason.

The final fix:

change the first string in DBI->connect from



Turns out, like in PHP, the DBI module allows us to specify the mysql
socket to use.

I am sorry if this is the wrong forum for this, I just lost 2-3 hours
of my life trying to figure this one out if this posting had existed,
I might have saved a little time.

Site Timeline