1

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.```
Jossy
  • 589
  • 2
  • 12
  • 36
  • Which directory did you install MySQL in? You typically need to add its `bin` directory to `PATH`. For example: `PATH="$PATH:/usr/local/mysql-8.0.19-macos10.15-x86_64/bin"` – Håkon Hægland Sep 08 '21 at 17:28
  • Does this answer your question? [Trying to install Perl-Mysql DBD, mysql\_config can't be found](https://stackoverflow.com/questions/4729722/trying-to-install-perl-mysql-dbd-mysql-config-cant-be-found) – Dada Sep 08 '21 at 17:32
  • @HåkonHægland - thanks for this. That definitely got rid of the config file error but I'm now into a new set of errors :( – Jossy Sep 08 '21 at 18:54
  • @Dada - It looks like I could be missing xxx now but I'm not sure how to install it. I've tried `sudo apt-get install libmysqlclient-dev` from the first answer but I get the error; `sudo: apt-get: command not found` – Jossy Sep 08 '21 at 18:56
  • @Jossy *"I'm now into a new set of errors"*: see also [this](https://github.com/perl5-dbi/DBD-mysql/issues/322) issue – Håkon Hægland Sep 08 '21 at 18:59
  • @HåkonHægland - sorry I meant to say I'd updated my post with the errors! – Jossy Sep 08 '21 at 19:04
  • @Jossy I have never worked with a Mac, but [libmysqlclient15-dev on macs?](https://stackoverflow.com/q/1857861/4990392) seem to show how to install `libmysqlclient-dev` on Mac. – Dada Sep 08 '21 at 19:07
  • @Jossy *"Library not loaded: @rpath/libmysqlclient.21.dylib"* I think this bug has been reported [here](https://github.com/perl5-dbi/DBD-mysql/issues/322). The reason for this error is described in my comments to [this](https://github.com/mattn/p5-Devel-CheckLib/issues/31) issue – Håkon Hægland Sep 08 '21 at 19:43
  • @Jossy As a workaround: Can you try to add `/usr/local/mysql-8.0.26-macos11-x86_64/lib` to the environment variable `DYLD_LIBRARY_PATH` and then try to install the module without running the test (i.e run this command: `cpan -T DBD::mysql`) – Håkon Hægland Sep 08 '21 at 19:57
  • @Jossy Btw. are you using the system perl? (I would recommend using perlbrew) – Håkon Hægland Sep 08 '21 at 19:58
  • @HåkonHægland - thanks for sticking with me :) I've now installed perlbrew (it took ages and failed once). Still getting an error on the DBD installation but I was able to install DBI and another module very easily! Any ideas on where we could go from here? – Jossy Sep 08 '21 at 23:07
  • @Jossy As mentioned in my previous comment, could you first try to install the module without running the tests ? – Håkon Hægland Sep 08 '21 at 23:33
  • @HåkonHægland - I added `/usr/local/mysql-8.0.26-macos11-x86_64/lib` to the environment variable `DYLD_LIBRARY_PATH` and ran `cpan -T DBD::mysql` - getting the same error as before :-( `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` Could the issue be to do with the `philipjoss` username? – Jossy Sep 09 '21 at 07:42
  • To everyone getting to the end of this long chain - well done and also... I found the answer here https://stackoverflow.com/a/56196487/11277108. Thanks to @HåkonHægland and Dada for helping out!!! – Jossy Sep 09 '21 at 08:21
  • Are you running the correct `cpan` command? You need to run the one that came installed with `perlbrew` ? It should happen automatically though if you run `perlbrew use ....` first – Håkon Hægland Sep 09 '21 at 08:22
  • 1
    @HåkonHægland - I hadn't tried `perlbrew use` but everything is sorted now - posted link to an answer I found! Thanks again for helping out! – Jossy Sep 09 '21 at 10:07

0 Answers0