You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Steve Wilder <st...@matrixInteractive.net> on 2000/11/28 05:29:53 UTC
mod_perl/Embperl/MySQL problem
Hi all.
I've done this several times on other servers without any problems, but
for some reason, I can't get any Perl-DBI script to talk to my MySQL
database when Apache is involved. Command line, it works fine, but
mod_perl/Embperl stuff causes a segmentation fault. It seems like as soon
as I touch the DataSource for MySQL, it dies.
I've been dinking with this for a week on and off, with no luck. I hope
no one minds, but I'm going to paste some code, and error log stuff here:
http://gmbp.m8rix.net/steve/test.phtml
Looks like this:
---------------------------------------
<html>
<head>
</head>
<body>
[-
#use CGI qw(:netscape :standard);
use DBI;
#use DBD::mysql;
#my $cgi = new CGI();
DBI->trace(4, "dbitrace.log");
-]
<p>
[+ scalar localtime() +]
<p>
<p>
[+ join("\<br\>", DBI->available_drivers()) +]
<p>
<br>
<pre>
Data Sources for MySQL = [# DBI->data_sources('mysql') #]
[-
@mysql_ds = DBI->data_sources('mysql');
-]
[$ foreach $ds (@mysql_ds) $]
Data src = [+ scalar $ds +]<br>
[$ endforeach $]
[+
$dbc_gmbp = DBI->connect("DBI:mysql:buypower", "www", "****",
{PrintError => 1,
RaiseError => 1});
+]
<br>
[# $sth = $dbc_gmbp->prepare("select * from role_desc"); #]
[# $dbc_gmbp->errstr #]
[# $sth->execute(); #]
[# $dbc_gmbp->errstr #]
[# while (@aRow = $sth->fetchrow_array) #]
[+ join("\t", @aRow) +]
[# endwhile #]
</pre>
[-
#$sth->finish;
$dbc_gmbp->disconnect;
-]
<br>
...End
</html>
---------------------------------------
If I uncomment the DBI->data_sources('mysql') part, it will come back with
an empty document. Which is what it does if I attempt to connect to the
database.
---------------------------------------
dbitrace.log looks like this:
---------------------------------------
DBI 1.14-nothread dispatch trace level set to 4
Note: perl is running without the recommended perl -w option
-> DBI->install_driver(mysql) for perl=5.00503 pid=11244 ruid=15 euid=15
install_driver: DBD::mysql loaded (version 2.0415)
New DBI::dr (for DBD::mysql::dr, parent=, id=)
dbih_setup_handle(DBI::dr=HASH(0x8dbc5ec)=>DBI::dr=HASH(0x8e52968),
DBD::mys
ql::dr, 0, Null!)
dbih_make_com(Null!, DBD::mysql::dr, 84)
<- install_driver= DBI::dr=HASH(0x8dbc5ec)
-> data_sources for DBD::mysql::dr (DBI::dr=HASH(0x8dbc5ec)~0x8e52968)
2 -> _ListDBs for DBD::mysql::dr (DBI::dr=HASH(0x8e52968)~INNER '')
imp_dbh->MyConnect: host = NULL, port = 0, uid = NULL, pwd = NULL
imp_dbh->MyConnect: client_flags = 0
---------------------------------------
tail /usr/local/apache/logs/error_log is real helpful:
[Tue Nov 21 17:41:55 2000] [notice] child pid 18449 exit signal Segmentation
fault (11)
As is /tmp/embperl.log:
[11244]MEM: Load /data/buypower/web/steve/test.phtml in
HTML::Embperl::DOC::_1
Any help/advice/places to look for help/ would be appreciated.
Thanks,
Steve Wilder
Matrix Interactive, Inc.
http://www.matrixinteractive.net/
Desk: 248.814.8235
Cell: 248.894.3128
Fax : 248.814.8236
Re: mod_perl/Embperl/MySQL problem
Posted by Neil Gunton <ne...@nilspace.com>.
Steve Wilder wrote:
>
> Hi all.
>
> I've done this several times on other servers without any problems, but
> for some reason, I can't get any Perl-DBI script to talk to my MySQL
> database when Apache is involved. Command line, it works fine, but
> mod_perl/Embperl stuff causes a segmentation fault. It seems like as soon
> as I touch the DataSource for MySQL, it dies.
>
> I've been dinking with this for a week on and off, with no luck. I hope
> no one minds, but I'm going to paste some code, and error log stuff here:
>
Steve,
I don't want to be too simplistic here, but I have found that reducing a
problem to its most minimalistic form is useful when debugging. I am
writing because I actually have been having no problems at all using
mod_perl/Embperl/Apache/MySQL. And I have been through several different
versions of each of these tools, all on Red Hat Linux 6.1 and 7.0. In
each case I have built apache, mod_perl, embperl and mysql from source,
rather than using RPMs. Maybe this makes a difference, I don't know. So
the first thing I would try is getting the latest (stable) versions of
all these packages in source form and compiling them on your system, and
see if all the tests run successfully.
Then, I would try the minimal case. Something like this:
use DBI;
$dsn = "DBI:mysql:mydatabase";
$dbh = DBI->connect ($dsn);
$query = $dbh->prepare ("select * from mytable");
$query->execute();
$record = $query->fetchrow_hashref();
I notice this form is a little different from the one you are using. For
example, you give more arguments to the call to connect(). Try the
simpler form instead. I might add that I configure mysql to have no
password for the root user. I do this because I don't have other Unix
users on my server, and it is protected by a firewall anyway. In any
case, it would be useful for you to set up a test database which could
be accessed simply, without passwords - just for testing. You get the
minimal case working, then build up from there.
Hope all this is of some use.
-Neil
Re: mod_perl/Embperl/MySQL problem
Posted by Gerald Richter <ri...@ecos.de>.
Hi,
which versions of Perl/Apache/mod_perl/Embperl you are using? RPMs or
compiled from the source? Is mod_perl loaded as DSO or staticly linked into
Apache?
Maybe it help loading DBI and DBD::mysql at Server startup time (you should
do this with Embperl anyway) e.g. in your httpd.conf
PerlModule HTML::Embperl
PerlModule DBI
PerlModule DBD::mysql
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
----- Original Message -----
From: "Steve Wilder" <st...@matrixInteractive.net>
To: <em...@perl.apache.org>
Sent: Tuesday, November 28, 2000 5:29 AM
Subject: mod_perl/Embperl/MySQL problem
>
> Hi all.
>
> I've done this several times on other servers without any problems, but
> for some reason, I can't get any Perl-DBI script to talk to my MySQL
> database when Apache is involved. Command line, it works fine, but
> mod_perl/Embperl stuff causes a segmentation fault. It seems like as soon
> as I touch the DataSource for MySQL, it dies.
>
> I've been dinking with this for a week on and off, with no luck. I hope
> no one minds, but I'm going to paste some code, and error log stuff here:
>
> http://gmbp.m8rix.net/steve/test.phtml
> Looks like this:
> ---------------------------------------
> <html>
> <head>
> </head>
>
> <body>
>
> [-
> #use CGI qw(:netscape :standard);
> use DBI;
> #use DBD::mysql;
>
> #my $cgi = new CGI();
>
> DBI->trace(4, "dbitrace.log");
> -]
>
> <p>
>
> [+ scalar localtime() +]
> <p>
> <p>
> [+ join("\<br\>", DBI->available_drivers()) +]
> <p>
>
> <br>
> <pre>
> Data Sources for MySQL = [# DBI->data_sources('mysql') #]
>
> [-
> @mysql_ds = DBI->data_sources('mysql');
> -]
> [$ foreach $ds (@mysql_ds) $]
> Data src = [+ scalar $ds +]<br>
> [$ endforeach $]
>
> [+
> $dbc_gmbp = DBI->connect("DBI:mysql:buypower", "www", "****",
> {PrintError => 1,
> RaiseError => 1});
> +]
> <br>
>
> [# $sth = $dbc_gmbp->prepare("select * from role_desc"); #]
> [# $dbc_gmbp->errstr #]
> [# $sth->execute(); #]
> [# $dbc_gmbp->errstr #]
>
> [# while (@aRow = $sth->fetchrow_array) #]
> [+ join("\t", @aRow) +]
> [# endwhile #]
>
> </pre>
>
> [-
> #$sth->finish;
> $dbc_gmbp->disconnect;
> -]
>
>
> <br>
> ...End
> </html>
>
> ---------------------------------------
>
> If I uncomment the DBI->data_sources('mysql') part, it will come back with
> an empty document. Which is what it does if I attempt to connect to the
> database.
>
> ---------------------------------------
>
>
> dbitrace.log looks like this:
> ---------------------------------------
> DBI 1.14-nothread dispatch trace level set to 4
> Note: perl is running without the recommended perl -w option
> -> DBI->install_driver(mysql) for perl=5.00503 pid=11244 ruid=15
euid=15
> install_driver: DBD::mysql loaded (version 2.0415)
> New DBI::dr (for DBD::mysql::dr, parent=, id=)
> dbih_setup_handle(DBI::dr=HASH(0x8dbc5ec)=>DBI::dr=HASH(0x8e52968),
> DBD::mys
> ql::dr, 0, Null!)
> dbih_make_com(Null!, DBD::mysql::dr, 84)
> <- install_driver= DBI::dr=HASH(0x8dbc5ec)
> -> data_sources for DBD::mysql::dr (DBI::dr=HASH(0x8dbc5ec)~0x8e52968)
> 2 -> _ListDBs for DBD::mysql::dr (DBI::dr=HASH(0x8e52968)~INNER '')
> imp_dbh->MyConnect: host = NULL, port = 0, uid = NULL, pwd = NULL
> imp_dbh->MyConnect: client_flags = 0
> ---------------------------------------
>
> tail /usr/local/apache/logs/error_log is real helpful:
> [Tue Nov 21 17:41:55 2000] [notice] child pid 18449 exit signal
Segmentation
> fault (11)
>
> As is /tmp/embperl.log:
> [11244]MEM: Load /data/buypower/web/steve/test.phtml in
> HTML::Embperl::DOC::_1
>
> Any help/advice/places to look for help/ would be appreciated.
>
> Thanks,
>
> Steve Wilder
> Matrix Interactive, Inc.
> http://www.matrixinteractive.net/
> Desk: 248.814.8235
> Cell: 248.894.3128
> Fax : 248.814.8236
>
----------------------------------------------------------------------------
----
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org