Hi,
I can easily connect to a remote MySQL server using the DBI module in my Perl scripts. However, when I try to use the same connection settings/properties from within a CGI script AND call it via browser, the MySQL connection fails to establish.
There are no helpful errors/warnings being logged either in the apache error log, or the browser, in spite of using
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);I'm getting the following error:
DBI connect('$db_name:$remote_host_IP:$port','$username',...) failed: Can't connect to MySQL server on '$remote_host_IP' (13) at /var/www/cgi-bin/$script_name.cgi line 25Of course the logs contain the actual values of the abovementioned variables
I'm using the following connection string
$dbh = DBI->connect($ds, $uname, $pwd,{RaiseError => 1 }) or die "$DBI::errstr Could not connect: $!<br>";Strangely, the exact same CGI script works fine when executed from the terminal (from within same cgi-bin directory), even after sudo'ing to the apache/tomcat user
On the other hand, phpMyAdmin works great on the machine, connecting to a different MySQL server on localhost.
I'm using CentOS Release 5.8. However, before writing the scripts, I had to install mysql server and client from a third-party repository via yum, because CentOS would not update PHP and the related php-mysql library to 5.2 or higher, for which a mysql upgrade was necessary (which also could not be done under my setup).
Which environment variables/libraries can I further look into to debug this issue?
Thanks a lot
In reply to CGI script connecting via terminal but not via browser by nkrgupta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |