bnanaboy has asked for the wisdom of the Perl Monks concerning the following question:

I have been trying (unsuccessfully) all day to install the DBD::mysql package (DBI was installed yesterday). I work in the computer support department at the university I attend, and the basic way things work here is if something isn't important or urgent enough for my boss to have to deal with, he assigns it to whoever is available, so everything is a hodge-podge of Unix shell scripts, PHP, Javascript, Perl, whatever the person who was assigned the project happened to be (somewhat) proficient in. I am trying to re-write a shell script in Perl to make the database queries more efficient--and because I thought it would be easier to re-write the script than learn how to format the output exactly how it needs to be done in Shell.

The problem I have come up against now is that the MySQL server is running on a socket in a location other than the default MySQL socket, so the DBD::mysql package doesn't pass the make test stage. The test script uses the outdated (and no longer supported) Perl Mysql object of the form Mysql->connect($host, $db, $user, $pw); and does not support user-specified sockets, so I get an error message saying the server is not running or I do not have access rights to the database. I tried changing the test script to use DBI->connect($dns, $user, $pass); which allows you to specify the socket and configuration file to use, but DBI doesn't support the Mysql object method getserverinfo used in the test script. Any suggestions on what to try now? Should I assume since I know what's causing the errors that DBD::mysql is safe to install and skip the make test stage? (I hate to assume...)

Replies are listed 'Best First'.
Re: Installing DBD::mysql
by bart (Canon) on Oct 15, 2002 at 21:21 UTC
    The problem I have come up against now is that the MySQL server is running on a socket in a location other than the default MySQL socket, so the DBD::mysql package doesn't pass the make test stage.
    I assume that by "socket", you mean port number? I think MySQL uses 3306 by default.

    Well, when I run perl Makefile.PL, it asks which host the test database to use is on, and one possibility it offers is the host:port syntax. So: just enter your special portnumber here, after the colon, with "localhost" or the empty string in front of the colon.

    I did notice that it only does so with a freshly decompressed archive. So delete it all, decompress the archive again, chdir and do `perl Makefile.PL`.

Re: Installing DBD::mysql
by runrig (Abbot) on Oct 15, 2002 at 20:34 UTC
    Should I assume since I know what's causing the errors that DBD::mysql is safe to install and skip the make test stage?

    Since you've done the 'make', you can write your own test script before the install, by including a 'use lib' statement to the directory you've built DBD::mysql in. E.g.:

    use lib qw( /path/to/src/DBD-mysql.0.0.1/blib/lib /path/to/src/DBD-mysql.0.0.1/blib/arch ); use DBI; etc...
    Those paths may not be exactly correct, of course... :-)
Re: Installing DBD::mysql
by l2kashe (Deacon) on Oct 15, 2002 at 20:45 UTC
    Honestly.. If your code compiled cleanly, but you aren't passing make test, I would complete the compilation (make install), and then write a quick script to access a DB and pull a line from a table. If that doesnt work, then I would roll back and try again.

    I've been doing sysadmin work for a few years now, and find that some (make test)s, don't acurately poll the system, or do not have as robust a "test" suite as I would like. As long as during configuration/compilation I do not see errors, for the software itself or components I need, I attempt a make test. If after clean compilation, make tests moan, I generally install and then right my own tests.. Sometimes quick ones, other times I've spent alot more time that I should testing.. It all depends on the module/software in question.

    Try a make install, make sure you can use the methods you need to get your job done now, get that done, then decide if you really need make test to finish clean.. If so happy hacking, if not happy hacking :)

    /* And the Creator, against his better judgement, wrote man.c */