c/fe

http://d.hatena.ne.jp/uzulla から移行しました。

Xampp for MacのPerlにDBIとDBD:Mysqlを入れる

知り合いの人がXamppがどうたら、といっていたので(あんまり関係がない)

# sudo /Applications/XAMPP/xamppfiles/bin/perl -MCPAN -e shell
Cpan> install DBI

これでDBIは普通に入ります。
問題はDBD:Mysqlで、普通に入れようとすると

Can't exec "mysql_config": No such file or directory at ./Makefile.PL line 82.

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 464.
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 464.
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 464.
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 464.
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 464.
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 464.
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

こんな文句を言われます。
mysql_configがみつからないってさ、これは/Applications/XAMPP/xamppfiles/bin/mysql_configにあるのですが、Pathとか通ってないので、ダメだそうで。

この時は一回Cpan shellをぬけて、

# cd ~/.cpan/sources/authors/id/C/CA/CAPTTOFU/
# sudo su 
# tar xvzf DBD-mysql-4.012.tar.gz  <-勿論ファイル名が違う場合有り
# cd DBD-mysql-4.012
# /Applications/XAMPP/xamppfiles/bin/perl ./Makefile.PL --mysql_config=/Applications/XAMPP/xamppfiles/bin/mysql_config
(略
# make 
# make install

これで入ります。
CPAN Shellでもオプション付ける方法あるらしいけど、Slackware時代からのTarball信者の私は昔からコレです。


Xampp for OSXはやろうとおもえば大抵の事ができるので、すばらしいですね。