1

I want to connect the MySQL client by using below perl5.18 script on macOS.

File name: db.pl

#!usr/bin/perl

use DBI;
use strict;

my $driver = "mysql";
my $database = "test";
my $dsn = "DBI:$driver:database=$database";
my $userid = "root";
my $password = "qawseder123";

my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::errstr;

my $sth = $dbh->prepare("INSERT INTO test
                       (first_name, last_name, sex, age)
                         values
                       ('john', 'poul', 1, 30)");
$sth->execute() or die $DBI::errstr;
$sth->finish();
$dbh->commit or die $DBI::errstr;

When I execute perl db.pl, it gives below error.

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (you may need to install the DBD::mysql module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.4/darwin-thread-multi-2level /Library/Perl/Updates/5.18.4 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at (eval 4) line 3. Perhaps the DBD::mysql perl module hasn't been fully installed, or perhaps the capitalisation of 'mysql' isn't right. Available drivers: DBM, ExampleP, File, Gofer, Mem, Proxy, SQLite, Sponge. at db.pl line 12.

To resolve above error below commands are executed.

perl -MCPAN -e shell

install DBD::mysql

But it gives below error when I execute install DBD::mysql.

wrong result: 'mysqlclient', 'ssl', 'crypto' Warning: No success on command[/usr/bin/perl Makefile.PL] 'YAML' not installed, will not store persistent state DVEEDEN/DBD-mysql-4.050.tar.gz /usr/bin/perl Makefile.PL -- NOT OK Running make test Make had some problems, won't test Running make install Make had some problems, won't install Failed during this command: DVEEDEN/DBD-mysql-4.050.tar.gz : writemakefile NO '/usr/bin/perl Makefile.PL' returned status 512.

Would you guide me?

netajik
  • 196
  • 1
  • 4
  • 15
  • The pertinent bit is `wrong result: 'mysqlclient', 'ssl', 'crypto'` (and maybe things that came before that). Not sure what produces that or what it means. Possible duplicate of https://stackoverflow.com/q/53865612/589924. – ikegami Nov 21 '19 at 12:28
  • Also found this: https://github.com/perl5-dbi/DBD-mysql/issues/161#issuecomment-449962061 – ikegami Nov 21 '19 at 12:29
  • This might be the correct solution: https://github.com/perl5-dbi/DBD-mysql/issues/161#issuecomment-531742015 – ikegami Nov 21 '19 at 12:31

0 Answers0