Msql Library for Perl
It seems that each time one installs the Msql libraries for perl,
regardless of which version (Msql.pm, "Mysql," DBD, etc), they all have
an annoying association with a particular database. The build process
compiles in paths to particular libraries. In particular, it compiles
in the path to the msql.conf file. There is no simply way to defeat
this behavior.
The workaround is to have an msql directory and a perl library
directory which are a matched pair. You need one pair of these per
msql daemon you intend to run. In theory, a single daemon can serve
multiple databases. It is not necessary to serve one database per
daemon.
In point of fact, the msql directory only needs to be separate
enoughto have a separate msql.conf file. The bin, lib, include, and
other directories within it can all be symbolic links to one main
msql installation.
Here's an overview of the process:
- Create an msql directory, with your properly configured msql.conf.
- Build an instance of the Msql perl library which points at that
directory.
- Modify your perl script to pull in that particular version of the Msql
perl library.
Detailed Overview
- Install msql version 2 which you can get at
http://www.hughes.com.au/
Install it in a local directory where you're going to be storing your database
(e.g. /home/userid/msql)
- Get the database up and running. Edit your msql.conf file in
/home/userid/msql to reflect which machine, port, and so on you'll
be using. This is critical.
- Get the sources for the "Msql-Mysql" perl package. Extract them.
To build them correctly, you must do the following:
a. Run "/usr/cs/bin/perl Makefile.PL" in the main directory.
b. Answer several questions. Here they are:
You don't have installed the DBI module, version 0.91 or later. I
cannot continue installing the DBD modules.
You have two options:
- Abort now, install the DBI module (available at any CPAN mirror, see
'perldoc CPAN') and rerun me. (Recommended)
- Disable installation of the DBD modules and install the non-DBD drivers
only.
Do you want to abort now? [y]
ANSWER "n"
Which DBMS do you want to use?
- MySQL
- mSQL
- Both
Enter your choice: [3]
ANSWER "2"
Where is your msql installed? Please tell me the directory that contains the
subdir include/. [/usr/local/Hughes]
ANSWER your msql directory (e.g. /home/userid/msql/msql)
c. Run "make". Watch it build.
- Make a perl directory somewhere in your database area. (e.g. /home/userid/msql/perl)
This will house the perl libraries which correspond to a particular database.
- Copy several files into your perl directory. "/tmp/Mysql" is the location of the perl stuff I
just built.
cd /tmp/Mysql
cd blib/arch
mv auto /home/userid/msql/perl
cd ../lib
mv Msql* Mysql* /home/userid/msql/perl
- Edit your script to tell perl to load libraries from that directory. Instead of "require Msql;"
use the following two lines:
- use lib "/home/userid/msql/perl";
- require "/home/userid/msql/perl/Msql.pm";
Good luck!