39

Here's the output:

Ian-MacBook-Pro:DBD-mysql-4.011 ianseyer$ sudo Perl Makefile.PL
Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.

Cannot find the file 'mysql_config'! Your execution PATH doesn't seem 
not contain the path to mysql_config. Resorting to guessed values!
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
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 454.
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 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the 
database user 'root' 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 'root'@'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 454.
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 454.
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 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Failed to determine directory of mysql.h. Use

  perl Makefile.PL --cflags=-I

to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type

  perl Makefile.PL --help

I've researched the issue and tried making a symlink to no avail.

Do I have to compile this myself?

Linus Kleen
  • 33,871
  • 11
  • 91
  • 99
ian
  • 593
  • 2
  • 6
  • 16

10 Answers10

61

If you installed the mysql server that everybody installs: sudo apt-get install mysql-server (or something like this)

you are missing a few extra files on which the makefile for this perl module depends.

You can try to work around this issue by installing the following package:

sudo apt-get install libmysqlclient-dev 

REFERECE: http://cpansearch.perl.org/src/RUDY/DBD-mysql-2.9008/INSTALL.html#configuration

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
99Sono
  • 3,554
  • 27
  • 39
18

Applying to ubuntu/debian users (I'm running U-12.0.4), it was suggested above that users do:

sudo apt-get install libmysqlclient-dev

But then there is another problem with the maketest portion of the install where the "password: NO" FAILED. To bypass that test, just use force:

sudo cpan -f DBD::mysql
Damian Green
  • 633
  • 2
  • 8
  • 13
10

Install the mysql-devel package that pertains to your distro and mysql server version.

AaronC
  • 101
  • 1
  • 2
  • This is the correct answer. Also, please note that if you're using a fork of mysql you have to install the devel package matching that fork and version e.g. `Percona-XtraDB-Cluster-devel-56`. – dr_ Apr 18 '16 at 13:10
  • At least what it needs with CentOS. Thanks! – BurninLeo Dec 20 '17 at 13:43
10

if u r using ubuntu , u can easily install using the below cmd

    sudo apt-get install libdbd-mysql-perl

for more detail check the cpan install.pod consist detail about other Linux flavor

made_in_india
  • 2,109
  • 5
  • 40
  • 63
4

You just need mysql-server and mysql-devel installed locally so that cpan can build the module, you can probably remove the mysql server afterwards.

Jack
  • 41
  • 1
3

If you try to install via CPAN you cannot, as far as I know, set the --mysql_config option directly. And, including the directory containing mysql_config in the PATH environment variable does not seem to help.

However, if you do have the file mysql_config available somewhere, you can do the following to make the install succeed:

ln -s /path/to/mysql_config /usr/local/bin/

Then, remove the symbolic link after the DBD::mysql installation.

The tests during install will still fail, unless you have installed MySQL in some central/default location on your system, but installation will still succeed.

If you do not have mysql_config available, you can get it from a tar.gz download of the MySQL Community Server from mysql.com. It will be located in the bin/ subdirectory of the extracted files. If you want to have MySQL installed on your system, a better option is probably to download the RPMs and install them, or install via the package management system of your OS.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
JohnH
  • 46
  • 2
3

Find the script mysql_config.pl under your MySQL directory, and run Makefile.PL like:

perl Makefile.PL --mysql_config=/path/to/mysql-5.x.y.zzz/bin/mysql_config.pl
mob
  • 117,087
  • 18
  • 149
  • 283
2

Try yum install mariadb-devel for CentOS 7 and then run the required Perl module installation such as cpan DBD::mysql

Eranga Atugoda
  • 131
  • 1
  • 6
0

I was getting make test errors. This helped me;

perl Makefile.PL  --testuser=bob  --testpass=bobtest
PodTech.io
  • 4,874
  • 41
  • 24
0

I solved installing libmariadbclient-dev, libmariadb-dev and mariadb-client on debian 9.13

apt install mariadb-client libmariadbclient-dev libmariadb-dev
AlbertFont
  • 36
  • 4