PerlBrew DBD::mysql – Configure failed

images

Quick post on a issue that I had trying to install DBD::mysql in my PerlBrew installation on Natty-Ubuntu.

PerlBrew (PB) is AWESOME – it gives you your own little universe of perl, completely installed in user space, so you have no need of sudo privlidges. Say your sysadmin doggedly refuses to update beyond 5.8 to something more modern (5.10 AT LEAST for crying out loud), then PB is definitely for you. You can also easily install packages and modules using cpanm, which comes bundled with it (install it with ‘$perlbrew install-cpanm’ whilst switched into your perl installation of choice – it will manage all the library extensions etc. for you ).

My issue was this; I had just installed PerlBrew and installed perl-5.14.2 (the latest stable release). My work requires DBI and use of MySQL (already installed), so I grabbed DBI with cpanm – no problems so far:

$ cpanm DBI

--> Working on DBI
Fetching http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.618.tar.gz ... OK
Configuring DBI-1.618 ... OK
Building and testing DBI-1.618 ... OK
Successfully installed DBI-1.618 (upgraded from 1.612)
1 distribution installed

Nice and easy. I then went on to try to install DBD::mysql

$ cpanm DBD::mysql

--> Working on DBD::mysql
Fetching http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.020.tar.gz ... OK
Configuring DBD-mysql-4.020 ... N/A
! Configure failed for DBD-mysql-4.020. See /home/sardar/.cpanm/build.log for details.

Oh dear. This is usually when I say to myself something like ‘do I really need to use PerlBrew? Maybe I could hack together something another way that works just as well’. Well, for once I pushed on and looked at the log:

Can't exec "mysql_config": No such file or directory at Makefile.PL line 478.
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 478.
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 478.

URGH! It’s looking for a file called mysql_config. From googling, I found that this is actually a file installed alongside MySQL – something I thought was already installed. Dispair. Flail at the keyboard at bit. Dispair some more. Google a bit more. Install some pointless packages. EVENTUALLY, through trial and error I find the solution:

Solution: Install the package ‘libmysqlclient-dev’ through aptitude.

Following that:

$ cpanm DBD::mysql

--> Working on DBD::mysql
Fetching http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.020.tar.gz ... OK
Configuring DBD-mysql-4.020 ... OK
Building and testing DBD-mysql-4.020 ... OK
Successfully installed DBD-mysql-4.020 (upgraded from 4.016)
1 distribution installed

Success. I’m guessing that the mysql_config file is in this package. Who knows (or cares now) why. I hope this saves someone else some time!

2 Responses

Leave a Reply to pancake Cancel reply

*