use DBI; # connect to localhost or remote host by specifying its ip address or hostname my $HOST = 'x.x.x.x'; # port , usually 3306 my $PORT = 3306; # database name my $DB = 'somedb'; my $dsn = "DBI:mysql:database=$DB;host=$HOST;port=$PORT";