This section provides a tutorial example on how to install Perl modules to access MySQL database server with Perl scripts.
Here is what we need to access MySQL database from Perl programs:
Perl implementation.
MySQL database server.
Perl DBI module.
Perl DBD::mysql module.
For Perl implementation, I have installed ActivePerl on my Windows system. See my other book
"Herong's Notes on Perl" for detail information.
To install MySQL server, see my other tutorial book "Herong's Tutorial Notes on SQL".
Perl DBI (Database Interface) module is the basic abstraction layer for working with external
database servers. If DBI module is not available on your Perl installation,
you can go to http://search.cpan.org/dist/DBI/ and download DBI-1.42.tar.gz.
But installing DBI module from the .tar file seems too complicated.
Another easy way to install the DBI module is to use PPM (Perl Package Management)
directly from Internet, if you have ActivePerl installed:
I don't know how PPM exactly works. My guess is that it comes with a list of
modules (packages), not installed, but defined with information about where
to go on the Internet to get them and how to install them. Installing additional
modules is so easy in this way, as you can see from this example. But I feel
that there is a security risk here by allowing PPM to interact with Internet
freely without you knowing what it is doing exactly.
The DBD:mysql module is the database driver for MySQL required by the DBI module.
It can also be installed by PPM, if you have ActivePerl installed: