Massyn has asked for the wisdom of the Perl Monks concerning the following question:

#!/fellow/monks.pl

I love PPM with ActiveState Perl. Just the idea of saying "install dbd-mysqlpp" and it's all done. That's why I loaded ActiveState 5.8.0 on my Redhat box...

My DBI-DBD app to MySQL is working fine on my Linux machine, where I'm running mySQL and my CGI's on, however, when I try to run my CGI on another web server accessing the database across the network, all the wheels fall off.

$mwsdbh = DBI->connect("DBI:mysqlPP:database=$db;host=$server;port=$po +rt", $user, $passwd)

On my local machine (without the port=$port bit), I set $server to 'localhost', and everything works fine, because it uses /tmp/mysql.sock to do the communication, however, when I specify $port=3306 and $server=192.168.0.2 (my Linux IP), I get this error..

[Thu Dec 12 10:04:43 2002] [error] [client 192.168.0.127] script not f +ound or unable to stat: /home/httpd/cgi-bin/debugmwslib.pl DBI->connect(database=mwsdb;host=192.168.0.2;port=3306) failed: Timeou +t of authentication at /usr/local/ActivePerl-5.8/lib/site_perl/5.8.0/ +DBD/mysqlPP.pm line 109 at mwslib.pl line 1143 Can't call method "prepare" on an undefined value at mwslib.pl line 97 +5. Compilation failed in require at /home/httpd/cgi-bin/mws/debugmwslib.p +l line 4.

I've done a telnet to 192.168.0.2:3306, and it works, so the port is active. Any idea what I'm doing wrong? I'll need this to split the database and webserver to different hardware.

Thanks!

#!/massyn.pl

You never know important a backup is until the day you need it.

Replies are listed 'Best First'.
Re: DBD-mysqlpp can't connect remotely
by rdfield (Priest) on Dec 12, 2002 at 09:19 UTC
    I'm no mySQL expert, but the first place I would look would be the first line of the error stack (in my experience, anything after the first line is usually irrelevent, ie caused by whatever caused the first one), therefore...
    script not found or unable to stat: /home/httpd/cgi-bin/debugmwslib.pl
    would seem to be the problem, rather than the mySQL DBD library.

    rdfield

      It would seem that way, but something strange is going on...

      When the CGI connects to mySQL on the same box via /tmp/mysql.sock, the script works fine. When I change it to connect via port 3306, I get this error.

      Now you showed me something interesting... The problem in /home/httpd/cgi-bin/debugmwslib.pl. This is not the script location -- it is /home/httpd/cgi-bin/mws/debugmwslib.pl, and it is the same location where I run it from (eg. http://192.168.0.2/cgi-bin/mws/debugmwslib.pl). </home/httpd/cgi-bin/debugmwslib.pl

      I do not have any redirection HTML code.

      Here's the script output when I run it from the command line (trying port 3306)

      root@morpheus:/home/httpd/cgi-bin/mws# ./debugmwslib.pl Content-type: text/html DBI->connect(database=mwsdb;host=192.168.0.2) failed: Timeout of authe +ntication at /usr/local/ActivePerl-5.8/lib/site_perl/5.8.0/DBD/mysqlP +P.pm line 109 at mwslib.pl line 1145 <html> <link REL="STYLESHEET" TYPE="text/css" HREF="/mwsstyle.css"> <head> <META HTTP-EQUIV="Expires" CONTENT="Tue, 2 Jan 1996 12:00:00 GMT"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> </head> <h1>Massyn Web Security</h1> Can't call method "prepare" on an undefined value at mwslib.pl line 97 +7. Compilation failed in require at ./debugmwslib.pl line 4. root@morpheus:/home/httpd/cgi-bin/mws#

      As said previously, when I connect to "localhost", everything works fine. I'm really confused why this is happening, and I really need to split the database and web server components.

      Thanks!

      #!/massyn.pl The more I learn, the more I realize I don't know. Albert Einstein 1879-1955