rajeshkumar created the topic: connect to my MySQL database using Perl?
$database = “DBNAME”;
$hostname = “DBSERVER”;
$port = “3306”;
$username = “DBUSERNAME”;
$password = ‘DBPASSWORD’;
$dsn = “DBI:mysql:database=$database;host=$hostname;port=$port”;
$dbh = DBI->connect($dsn, $username, $password) or die(“Could not connect!”);
$sql = “SELECT * FROM mytable”;
$sth = $dbh->prepare($sql);
while(($column1, $column2) = $sth->fetchrow_array)
print “C1 = $column1, C2 = $column2n”;
where DBNAME, DBUSERNAME, and DBPASSWORD are your database name, database username and database password, and where DBSERVER is your database server.
Twitt me @ twitter.com/RajeshKumarIn