I have a network with 2 FreeBSD servers configured with Apache.
Both servers runs PERL with DBI.
Now I want to connect from one server to a database on the other one.
The following script works well for a local database:
my ($dbname) = "lci";
my ($user) = "www";
# connect and returns handle to DB connection
my($dbh) = DBI->connect("dbi:Pg:dbname=$dbname",$user)
|| die "couldn't connect: $DBI::errstr";
But this one doesn't work for a remote database:
my ($dbname) = "aiwar;host=205.205.189.1;port=81";
my ($user) = "pgsql";
my $pass = "*****"; # my password isn't actually stars :)
# connect and returns handle to DB connection
my($dbh) = DBI->connect("dbi:Pg:dbname=$dbname",$user,$pass)
|| die "couldn't connect: $DBI::errstr";
My error log returns:
Apache/1.3.9 (Unix) mod_perl/1.22 configured -- resuming normal operations
DBI->connect(dbname=aiwar;host=205.205.189.1;port=81) failed: could not
connect to server: Connection refused
at /usr/local/lib/perl5/site_perl/5.005/lci.pm line 41
What am I doing wrong?
I did other tests also using these examples from the DBI doc:
dbi:DriverName:database_name
dbi:DriverName:database_name@hostname:port
dbi:DriverName:database=database_name;host=hostname;port=port
Anybody can help?!
Thanks!
Pierre