#!/bin/env perl # Script: DBD_mysql_test.pl # Purpose: A simple Perl script to check if MySQL DBD is functioning # in a system where Perl::DBI and Perl::DBD are expected to # be installed already. # ########################################################################## # Copyright (c) 2008 EVOKNOW, Inc. ########################################################################## use DBI; # Change the following settings according to your need ########################################################################## # Database hostname my $host = 'localhost'; # Database username to use my $user = 'your db username goes here'; # Database password to use my $pass = 'your db password goes here'; my $db = 'mysql'; ########################################################################## # No change required below this line. ########################################################################## # Connect to mysql database my $dbh = DBI->connect("DBI:mysql:database=$db;host=$host", "$user", "$pass", {'RaiseError' => 1}); # Create a statement to show version my $sth = $dbh->prepare("SELECT VERSION() as mysql_version"); # Execute the statement $sth->execute(); # Fetch data my $ref = $sth->fetchrow_hashref(); # Print results print "Your MySQL version is: " . $ref->{'mysql_version'} . "\n"; # Close the statement $sth->finish(); # Disconnect from the database.