use DBI; my $driver = 'mysql'; my $database = 'database_name'; # name of your database here my $username = undef; # your database username my $password = undef; # your database password # note that username and password should be assigned to if your database # uses authentication (ie requires you to log in) # we set up a connection string specific to this database my $dsn = "DBI:$driver:database=$database"; # make the actual connection - this returns a database handle we can use later my $dbh = DBI->connect($dsn, $username, $password); # when you're done (at the end of your script) $dbh->disconnect();