#!/usr/bin/perl -w use DBI; print "Content-Type: text/plain", "\n\n"; ## user database name $db ="mysql"; ## database user name $user = "root"; ## database password $pass = "PASSWORD"; ## user hostname : This should be "127.0.0.1" ## if you want to use localhost copy /etc/hosts file to ## /webroot/etc directory ## $host="127.0.0.1"; ## SQL query $query = "show tables"; $dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass); $sth = $dbh->prepare($query) or die "Can't prepare $query: $dbh->errstr\n"; $rv = $sth->execute or die "can't execute the query: $sth->errstr"; print "

Perl DBI Test

"; print "

Here is a list of tables in the database $db.

"; while (@row= $sth->fetchrow_array()) { my $tables = $row[0]; print "$tables\n
"; } #$rc = $sth->finish; exit(0);