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

Hello monks
I am trying to run a perl program that accesses from the
mysql db. Well when i run the pgm i get this error

mysql.pm not found in @INC ........
well i dont know how to make this right
any help would be appreciated

Title edit by tye

Replies are listed 'Best First'.
Re: mysql
by tachyon (Chancellor) on Apr 10, 2003 at 07:36 UTC

    The error means that mysql.pm was not found in @INC which are the library directories for perl so this module is not installed. However the problem probably runs far deeper than that as there is no module mysql.pm AFAIK that you can just use to access a mysql DB. There is a Mysql.pm and perl is case sensitive.... However this module is now considered obsolete. You will generally use DBI and DBD-mysql to achieve your goal.

    I suggest you post code and have a look at A short guide to DBI

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: mysql
by robartes (Priest) on Apr 10, 2003 at 07:39 UTC
    Are you using DBD::Mysql directly? In that case, you probably mistyped - you wanted to say use Mysql; whereas it appears you said use mysql;.

    If this is the case, consider switching to using DBI in conjuction with DBD::Mysql.

    If this is not the case, could you post the relevant portion of your script, so we can have a better look at the problem.

    CU
    Robartes-

      here is the code
      #!/usr/bin/perl -w use Mysql; $Host = "Localhost"; $Database = "test"; $User = "user"; $Passwd = ""; $dbh = Mysql->connect($Host, $Database, $User, $Passwd); $sql_statement = "select * from TEST"; $sth = $dbh->query($sql_statement); if (!defined $sth) { warn($dbh->errmsg); } while ( @row = $sth->fetchrow_array ) { print "$row[0]\t$row[1]\n"; } exit 0;
        Ah, in that case you probably do not have the module installed. Try installing it with CPAN.pm:
        $ perl -MCPAN -e 'install Bundle::DBD::mysql'
        If that works (if it's the first time you use CPAN.pm, you will have to answer some configuration questions), you should be set to go. But, as said, do consider switching to DBI (which is installed with the bundle).

        CU
        Robartes-