Connecting to MySQL with Perl

An example of connecting to MySQL with Perl.

Please consult the perl documentation located at

The following example connect’s to database “your_database_name” with username “your_mysql_user” and password “your_password”. You will need to substitute these values for your actual database, username, and password you setup in the Web Control Panel.

$mysql_server = "localhost";
$mysql_db = "your_database_name";
$mysql_user = "your_mysql_user";
$mysql_password = "your_password";
$dbh = DBI->connect("DBI:mysql:database=$mysql_db;host=$mysql_server", $mysql_user, $mysql_password, {'RaiseError' => 1});
Posted 2008-03-23 in Databases,Web Development