Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14120 reviews 1680 hosting providers

Questions & Answers

Using Perl DBI to access my MySQL database

Dec 29, 2012 by Susan3
Hi there

I am using Linux server for MySQL and I want to connect to MySQL database using Perl.
can anyone please advice mw how to do this?
Thanks

1 Answer

0 votes
Dec 29, 2012 by lionhost
To access MySQL database with Perl, you should use the DBI module .
1.After Log into your Linux web server using Secure Shell, type in the following at the prompt in order to include the DBI module in the script:
use DBI;
2.To connect to your database, type the following connection string:
$connection=DBI-
>connect("DBI:mysql:database=$yourdatabase;host=$MySQLserver-name:port=3306",
$your-username, $your-password);