1、 DBI下載地址:
https://cpan.metacpan.org/authors/id/T/TI/TIMB/DBI-1.636.tar.gz
1.1 解壓,編譯:
tar -zxvf DBI-1.636.tar.gz
cd DBI-1.636
perl Makefile.PL
make
make test
make install
2. DBD-mysql下載地址
http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.038.tar.gz
2.1 解壓,編譯:
tar -zxvf DBD-mysql-4.038.tar.gz
tar -zxvf DBD-mysql-4.006.tar.gz
cd DBD-mysql-4.006
perl Makefile.PL --mysql_config=/usr/bin/mysql_config
make
make test
make install

1 #測試是否成功: 2 #!/usr/bin/perl 3 4 use DBI; 5 $user="root"; 6 $passwd='xxxxxx'; 7 $dbh=""; 8 $dbh = DBI->connect("dbi:mysql:database=xxxx;host=xxxx;port=3309",$user,$passwd) or die "can't connect todatabase ". DBI-errstr; 9 $sth=$dbh->prepare("select * from t_test_table limit 2"); 10 $sth->execute; 11 while (@recs=$sth->fetchrow_array) { 12 print $recs[0].":".$recs[1].":".$recs[2]."\n"; 13 } 14 $dbh->disconnect;