How to Connect MySQL Using Perl

In This tutorial I will described simple connection script of PERL with mysql Database.
Currently I Am using DBI module of perl, where I am passing mysql parameters. Its tell compiler now we are using mysql database. DBI stands for “Database Interface” and is a database layer of PERL with simple interface for SQL queries.


You can also check other tutorial of perl,

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!C:/Perl/bin/perl.exe

# CONFIG VARIABLES
my $platform = "mysql";
my $database = "zftest";
my $host = "localhost";
my $port = "3306";
my $tablename = "users";
my $user = "root";
my $pw = "";
# DATA SOURCE NAME
my $dsn = "dbi:mysql:$database:localhost:3306";

# PERL DBI CONNECT
my $connect = DBI->connect($dsn, $user, $pw);