Search code examples
perlperl-moduledbi

Install DBI-mysql for Perl 5.18.xx


I am using perl 5.18.1.1800 with ppm 4.19 in a Windows 7 64 bit machine.

I need to use DBD-mysql to be able to access mysql from perl. But I get below error message:

use DBI();
my $dbh = DBI->connect("DBI:mysql:database=mydbname;host=localhost","myuser", "mypass",{'RaiseError' => 1})

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (you may need to install the DBD::mysql module)

So i tried to install DBD-mysql, but i don't have that listed in my PPM. In command line, when I tried to install, i get below error

ppm install DBD-mysql

ppm install failed: Can't find any package that provides DBD-mysql

I tried to download and install it, but it requires a C compiler which I don't have.

From DBD-mysql info page, there is no mentioning of Perl 5.18 support for the module.

So, should I revert back to 5.16.xx or the problem is something else?

Thanks,


Solution

  • DBD-mysql is available for ActivePerl-5.16.3.1604. Reverting back to that version is probably simpler than installing a compiler to build the package yourself.

    Activestate used Visual Studio to build DBD-mysql: http://ppm4.activestate.com/MSWin32-x86/5.16/1600/C/CA/CAPTTOFU/DBD-mysql-4.022.d/log-20120830T032945.txt

    enter image description here

    C:\>ppm install DBD-mysql
    Downloading ActiveState Package Repository packlist...done
    Updating ActiveState Package Repository database...done
    Syncing site PPM database with .packlists...done
    Downloading DBD-mysql-4.022...done
    Unpacking DBD-mysql-4.022...done
    Generating HTML for DBD-mysql-4.022...done
    Updating files in site area...done
      12 files installed