As someone else said, this is almost certainly a MySQL "problem".

When you connect from a local machine, you are known to MySQL as
'fred'@'localhost', and you have a particular identity.  When you connect
from a remote m/c, you are 'fred'@'some.tcp.ip.addr', and you have a totally
different identity.  You almost certainly need to get your MySQL
administrator to allow the remote identity to connect.

Rgds, GStC.


-----Original Message-----
From: Adam Saeed [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 13, 2004 7:55 AM
To: Perl Beginners List
Subject: remote database access in perl

I have written a simple program that should get data from a remote database,
but it is not working giving error:
DBI->connect(sugs:192.168.14.2) failed: Host 'www.sample.com' is not
allowed to connect to this MySQL server at testbug.pl line 12

code is below:
*****************
#! /usr/bin/perl -w

use DBI;
use strict;

my ($driver = 'mysql',$user = 'root',$pass = "",$database = 'sugs');

my $dsn = "DBI:$driver:$dbname:192.168.14.2";
my $dbh = DBI->connect($dsn,$user,$pass);

my $strsql="select * from products where product='L2'"; my $sth =
($dbh->prepare($strsql) || die "Query could not be executed " .
$dbh->errstr()); i$sth->execute(); while (my $row =
$sth->fetchrow_arrayref){ print join("\t", @$row), "\n"; } $sth->finish();
$dbh->disconnect();

Script is working fine on the host machine(192.168.14.2) but give error when
run from remote machine...
any suggestion?

Thanks
Adam

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to