日期:2014-05-16 浏览次数:20683 次
#!/usr/bin/perl use DBI; my $dbname="mysql"; my $location="localhost"; my $port="3306"; my $database="DBI:mysql:$dbname:$location:$port"; my $db_user="root"; my $db_pass="123456"; my $dbh=DBI->connect($database, $db_user, $db_pass); my $sql="select Host, User, Password from user"; my $sth=$dbh->prepare($sql); $sth->execute(); while(my @ref=$sth->fetchrow_array()){ print "Host:@ref[0],User:$ref[1],Password:$ref[2]\n"; } $dbh->disconnect