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
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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;