GENTOO系统源码安装perl+Mysql DBI/DBD
前提是已经安装好 mysql-5.1.30.tar.gz
1 perl-5.10.0.tar.gz
./Configure -des -Dprefix=$HOME/localperl
make test
make
install
2 DBI-1.607.tar.gz
/$HOME/perl Makefile.PL
make
make test
make install
3 DBD-mysql-4.010.tar.gz
/$HOME/perl Makefile.PL
make
make test
make install
4.CGI.pm-3.42.tar.gz
/$HOME/perl Makefile.PL
make
make test
make install
附录:测试perl脚本(来源于网上收集)
#!/bin/perl
# load module
use DBI;
# connect
my $dbh = DBI->connect("DBI:mysql:database=db2;host=localhost", "joe", "guessme", {'RaiseError' => 1});
# execute INSERT query
my $rows = $dbh->do("INSERT INTO users (id, username, country) VALUES (4, 'jay', 'CZ')");
print "$rows row(s) affected ";
# execute SELECT query
my $sth = $dbh->prepare("SELECT username, country FROM users");
$sth->execute();
# iterate through resultset
# print values
while(my $ref = $sth->fetchrow_hashref()) {
print "User: $ref-> ";
print "Country: $ref-> ";
print "---------- ";
}
# clean up
$dbh->disconnect();
阅读(1052) | 评论(0) | 转发(0) |