[prog] Perl/MySQL on LAN - reach with server
Elizabeth Barham
lizzy at soggytrousers.net
Mon Dec 2 14:34:05 EST 2002
Meryll Larkin <alwanza at oz.net> writes:
Hi Meryll,
> 1. Is there a security advantage to having the database on a
> separate machine than the server?
Not unless your database is exposing a tcp socket to the
world. MySQL can be configured to *not* do this so that your script
would communicate to it via unix sockets which are not exposed outside
the machine.
If you place the server on another host, though, you would need to
open up a tcp socket for it. Provided both the webserver and the mysql
server are behind a firewall, then this should not be a security
disadvantage *but* there will be a performance advantage by placing
the two services on different hosts.
> 2. How would I modify my Perl-CGI script to access the
> database on a different machine?
>
> I am currently using:
>
> my $DATA_BASE = 'dbi:mysql:Filename';
> my $dbh = DBI->connect ($DATA_BASE, $user, $password) ||
> $DISPLAY_MOD->print_punch_item ("can\'t connect
> to database: $!" . $DATA_BASE->errstr);
>
> Hey, it is PERFECTLY okay to tell me to RTFM, but PLEASE,
> point me to the correct "M".
<http://search.cpan.org/author/JWIED/DBD-mysql-2.1020/lib/DBD/mysql.pod>
esp: $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
hth, Elizabeth
More information about the Programming
mailing list