Can't install "DBD-mysql" on Mac

996 Views Asked by At

When running this command: perl -MCPAN -e 'install DBD::mysql' I get a really long output of different errors:

Reading '/Users/philipjoss/.cpan/Metadata'
  Database was generated on Tue, 07 Sep 2021 21:29:03 GMT
Running install for module 'DBD::mysql'
Checksum for /Users/philipjoss/.cpan/sources/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz ok
Configuring D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz with Makefile.PL
Can't exec "mysql_config": No such file or directory at Makefile.PL line 89.

Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'philipjoss' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.

mysql> grant all privileges on test.* to 'philipjoss'@'localhost' identified by 's3kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.PL --testuser=username

Can't exec "mysql_config": No such file or directory at Makefile.PL line 603.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 603.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 603.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
I will use the following settings for compiling and testing:

  cflags        (guessed) = -I/usr/local/mysql/include
  embedded      (guessed) = 
  libs          (guessed) = -L/usr/local/mysql/lib -lmysqlclient -lz -lm -lcrypt -lnsl
  mysql_config  (guessed) = mysql_config
  nocatchstderr (default) = 0
  nofoundrows   (default) = 0
  nossl         (default) = 0
  testdb        (default) = test
  testhost      (default) = 
  testpassword  (default) = 
  testport      (default) = 
  testsocket    (default) = 
  testuser      (guessed) = philipjoss

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
dyld: Library not loaded: @rpath/libmysqlclient.21.dylib
  Referenced from: /Users/philipjoss/.cpan/build/DBD-mysql-4.050-5/assertlib3PEYQc80
  Reason: image not found
Can't link/include C library 'crypt', 'nsl', aborting.
Warning: No success on command[/usr/bin/perl Makefile.PL]
  DVEEDEN/DBD-mysql-4.050.tar.gz
  /usr/bin/perl Makefile.PL -- NOT OK

There seems to be quite a few posts and articles on this kind of error but the solutions all seem to be Linux focussed. I think the key part of this is that I need a mysql_config file but I have no idea where to start on this!

MacOS is 11.5.2. Perl is 5.30.2. MySQL is 8.0.26.

Thanks in advance!


Update:

Adding the specific mysql directory to my path as suggested in the comments below has got me a little further along but I'm getting a whole different set of errors now:

Reading '/Users/philipjoss/.cpan/Metadata'
  Database was generated on Tue, 07 Sep 2021 21:29:03 GMT
Running install for module 'DBD::mysql'
Checksum for /Users/philipjoss/.cpan/sources/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz ok
Configuring D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz with Makefile.PL


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'philipjoss' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.

mysql> grant all privileges on test.* to 'philipjoss'@'localhost' identified by 's3kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.PL --testuser=username

I will use the following settings for compiling and testing:

  cflags        (mysql_config) = -I/usr/local/mysql-8.0.26-macos11-x86_64/include
  embedded      (guessed     ) = 
  ldflags       (guessed     ) = 
  libs          (mysql_config) = -L/usr/local/mysql-8.0.26-macos11-x86_64/lib -lmysqlclient -lssl -lcrypto -lresolv
  mysql_config  (guessed     ) = mysql_config
  nocatchstderr (default     ) = 0
  nofoundrows   (default     ) = 0
  nossl         (default     ) = 0
  testdb        (default     ) = test
  testhost      (default     ) = 
  testpassword  (default     ) = 
  testport      (default     ) = 
  testsocket    (default     ) = 
  testuser      (guessed     ) = philipjoss

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
dyld: Library not loaded: @rpath/libmysqlclient.21.dylib
  Referenced from: /Users/philipjoss/.cpan/build/DBD-mysql-4.050-6/assertlib3PoRLEqr
  Reason: image not found
dyld: Library not loaded: libssl.1.1.dylib
  Referenced from: /Users/philipjoss/.cpan/build/DBD-mysql-4.050-6/assertlib_CG2WA4d
  Reason: image not found
dyld: Library not loaded: libcrypto.1.1.dylib
  Referenced from: /Users/philipjoss/.cpan/build/DBD-mysql-4.050-6/assertlib0lH0wftp
  Reason: image not found
wrong result: 'mysqlclient', 'ssl', 'crypto'
Warning: No success on command[/usr/bin/perl Makefile.PL]
  DVEEDEN/DBD-mysql-4.050.tar.gz
  /usr/bin/perl Makefile.PL -- NOT OK

Update 2:

Following advice from the comments below I've switched to perlbrew and after one failure I've now finally got it installed (it took about 45 mins each time). Running my script now using perlbrew exec perl oncourt_update.pl now returns the original error: install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC. I've tried an installation using perlbrew use perl-5.34.0; cpan DBD::mysql however I get the following output:

Loading internal logger. Log::Log4perl recommended for better logging
Reading '/Users/philipjoss/.cpan/Metadata'
  Database was generated on Tue, 07 Sep 2021 21:29:03 GMT
Running install for module 'DBD::mysql'
Checksum for /Users/philipjoss/.cpan/sources/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz with Makefile.PL


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'philipjoss' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.

mysql> grant all privileges on test.* to 'philipjoss'@'localhost' identified by 's3kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.PL --testuser=username

I will use the following settings for compiling and testing:

  cflags        (mysql_config) = -I/usr/local/Cellar/mysql/8.0.26/include/mysql
  embedded      (guessed     ) = 
  ldflags       (guessed     ) = 
  libs          (mysql_config) = -L/usr/local/Cellar/mysql/8.0.26/lib -lmysqlclient -lz -lzstd -lssl -lcrypto -lresolv
  mysql_config  (guessed     ) = mysql_config
  nocatchstderr (default     ) = 0
  nofoundrows   (default     ) = 0
  nossl         (default     ) = 0
  testdb        (default     ) = test
  testhost      (default     ) = 
  testpassword  (default     ) = 
  testport      (default     ) = 
  testsocket    (default     ) = 
  testuser      (guessed     ) = philipjoss

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Can't link/include C library 'ssl', 'crypto', aborting.
Warning: No success on command[/Users/philipjoss/perl5/perlbrew/perls/perl-5.34.0/bin/perl Makefile.PL]
  DVEEDEN/DBD-mysql-4.050.tar.gz
  /Users/philipjoss/perl5/perlbrew/perls/perl-5.34.0/bin/perl Makefile.PL -- NOT OK

Looking at the output the line mysql> grant all privileges on test.* to 'philipjoss'@'localhost' looks strange as philipjoss isn't the username for localhost. Could this be something to do with the error? I note that the output states:

database user 'philipjoss' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.```
0

There are 0 best solutions below