Connect To MySQL using Perl

use DBI;
 
my $user = 'root';
my $password = 'root';
my $db = 'inventory';

my $link = DBI->connect(
   "DBI:mysql:database=$db", 
   $user, 
   $password
);

or connecting via network:

use DBI;
 
my $user = 'root';
my $password = 'root';
my $db = 'inventory';
my $host = 'localhost';
my $port = 8889;

my $link = DBI->connect(
   "DBI:mysql:database=$db;host=$host;port=$port", 
   $user, 
   $password
);