七福神(徳島県童学寺)


Date/Time: 2007:04:08 15:12:44
Camera: Panasonic
Model: DMC-LX2
Exporsure Time: 1/160
FNumber: 4.0
Aperture Value: 4.0
Focal Length: 6.3

Close

y2blog » OS X Server Tips : "DBD::mysql" のインストール

2

16

2008

OS X Server Tips : "DBD::mysql" のインストール

“DBD::mysql” のインストールについて


OS X Server 10.5 で MySQL 関係のリソースを入手する方法について、先の記事で紹介しましたが、CPAN から Perlのモジュールをインストールする方法については詳しく説明していませんでした.CPANから”DBD::mysql” モジュールをインストールするには、単純に


  cpan
  install DBD::mysql

としただけではエラーとなって上手くインストールできません.どうやら “DBD::mysql” モジュールが想定しているライブラリやインクルードファイルなどが、Mac OS X Server の 標準 MySQL 環境に含まれていないのが原因のようです.足りない MySQL関係のファイルをAppleのホームページからダウンロードして不足しているファイルをインストールします.

ダウンロードするファイルは:http://www.opensource.apple.com/darwinsource/other/MySQL-43.binaries.tar.gzです.

Mac OS X Server の デフォルト状態でのMySQLに関する情報を表示してみます.


$ /usr/bin/mysql_config
Usage: /usr/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/include -fno-omit-frame-pointer     -pipe]
        --include        [-I/usr/include]
        --libs           [-pipe -L/usr/lib -lmysqlclient -lz -lm]
        --libs_r         [-pipe -L/usr/lib -lmysqlclient_r -lz -lm]
        --socket         [/var/mysql/mysql.sock]
        --port           [3306]
        --version        [5.0.45]
        --libmysqld-libs [-pipe -L/usr/lib -lmysqld -lz -lm]
$


MySQL関係のライブラリやインクルードファイルが実際には上記の場所には有りませんので、”DBD::mysql” モジュールのインストールに失敗してしまうようです.

ダウンロードしたファイルを解凍し、そのディレクトリ内に含まれている “README” ファイルを参照してインストールします.


$ cd MySQL-43.binaries
$ ls -la
total 189096
drwxr-xr-x@  4 yasuaki  com.apple.monitor_all_services       136 Nov  8 05:55 .
drwxr-xr-x  27 yasuaki  staff                                918 Feb 16 00:34 ..
-rw-r--r--@  1 yasuaki  com.apple.monitor_all_services  96809787 Nov  8 05:48 MySQL-43.root.tar.gz
-rw-r--r--@  1 yasuaki  com.apple.monitor_all_services       406 Nov  8 05:55 README

$ sudo tar -xzvf MySQL-43.root.tar.gz -C /
Password:
./
./usr/
./usr/bin/
./usr/bin/comp_err
./usr/bin/innochecksum
./usr/bin/msql2mysql
./usr/bin/my_print_defaults
./usr/bin/myisam_ftdump
./usr/bin/myisamchk
./usr/bin/myisamlog
./usr/bin/myisampack
./usr/bin/mysql
./usr/bin/mysql_client_test
./usr/bin/mysql_config

【途中省略】 ./usr/bin/replace ./usr/bin/resolve_stack_dump ./usr/bin/resolveip ./usr/include/ ./usr/include/mysql/ ./usr/include/mysql/decimal.h ./usr/include/mysql/errmsg.h

【途中省略】 ./usr/lib/mysql/ ./usr/lib/mysql/libdbug.a ./usr/lib/mysql/libheap.a ./usr/lib/mysql/libmyisam.a ./usr/lib/mysql/libmyisammrg.a ./usr/lib/mysql/libmysqlclient.a

【以下省略】



もう一度MySQLに関する情報を表示してみると、今度は正しく MySQL のライブラリやインクルードファイルが参照されていますね.


$ /usr/bin/mysql_config
Usage: /usr/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/include/mysql -fno-omit-frame-pointer     -pipe]
        --include        [-I/usr/include/mysql]
        --libs           [-pipe -L/usr/lib/mysql -lmysqlclient -lz -lm]
        --libs_r         [-pipe -L/usr/lib/mysql -lmysqlclient_r -lz -lm]
        --socket         [/var/mysql/mysql.sock]
        --port           [3306]
        --version        [5.0.45]
        --libmysqld-libs [-pipe -L/usr/lib/mysql -lmysqld -lz -lm]



これで MySQL 側の環境が整いましたので、次に CPAN から “DBD::mysql” を取得してインストールします.


CPANから “DBD::mysql” を取得してインストールするには、コマンドラインから次のコマンドを打ち込むだけです.但し CPAN コマンドを実行したときに、初回だけは CPAN を利用する環境を整えるための様々な質問攻めに遭いますので、質問の内容が良く分からない場合はとりあえずリーターンキーを押していれば大丈夫でしょう.

最後の方で、どこのミラーサイトからダウンロードしてくるか尋ねられるので、なるべくご近所のサイトを指定しましょう. 私は (2) Asia → (5) Japan → (2) KDDI Lab を選びました.

CPANの環境が整うと、CPANのコマンドプロンプト cpan> が現れますので、”install DBD::mysql” とコマンドを入力して下さい.先程指定したサイトから自動的にダウンロードしてきて、Makefileの作成からインストールまで自動的にやってくれます.CPAN関係のファイルは、個人のホームディレクトリに “.cpan” という名前のディレクトリが作成され、その中に様々なファイルが置かれます.



$ sudo cpan

/System/Library/Perl/5.8.8/CPAN/Config.pm initialized.

CPAN is the world-wide archive of perl resources. It consists of about
100 sites that all replicate the same contents all around the globe.
Many countries have at least one CPAN site already. The resources
found on CPAN are easily accessible with the CPAN.pm module. If you
want to use CPAN.pm, you have to configure it properly.

If you do not want to enter a dialog now, you can answer 'no' to this
question and I'll try to autoconfigure. (Note: you can revisit this
dialog anytime later by typing 'o conf init' at the cpan prompt.)

Are you ready for manual configuration? [yes]


The following questions are intended to help you with the
configuration. The CPAN module needs a directory of its own to cache
important index files and maybe keep a temporary mirror of CPAN files.
This may be a site-wide directory or a personal directory.


First of all, I'd like to create this directory. Where?

CPAN build and cache directory? [/Volumes/Home/yasuaki/.cpan]

  【途中省略】

Select your country (or several nearby countries) [] 5
Sorry! since you don't have any existing picks, you must make a
geographic selection.

(1) ftp://ftp.dti.ad.jp/pub/lang/CPAN/
(2) ftp://ftp.kddilabs.jp/CPAN/
(3) ftp://ftp.nara.wide.ad.jp/pub/CPAN/
(4) ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
(5) ftp://ftp.u-aizu.ac.jp/pub/CPAN
(6) ftp://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
Select as many URLs as you like (by number),
put them on one line, separated by blanks, e.g. '1 4 5' [] 2  

Enter another URL or RETURN to quit: []
New set of picks:
  ftp://ftp.kddilabs.jp/CPAN/


commit: wrote /System/Library/Perl/5.8.8/CPAN/Config.pm
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

cpan>      ← 初期環境設定が終了し、コマンド入力待ちになった



引き続き “DBD::mysql” をインストールします.


cpan> install  DBD::mysql
CPAN: Storable loaded ok
Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/authors/01mailrc.txt.gz
Going to read /Volumes/Home/yasuaki/.cpan/sources/authors/01mailrc.txt.gz
CPAN: Compress::Zlib loaded ok
Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/modules/02packages.details.txt.gz
Going to read /Volumes/Home/yasuaki/.cpan/sources/modules/02packages.details.txt.gz
  Database was generated on Fri, 15 Feb 2008 03:30:53 GMT

  There's a new CPAN.pm version (v1.9205) available!
  [Current version is v1.7602]
  You might want to try
    install Bundle::CPAN
    reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...

Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/modules/03modlist.data.gz
Going to read /Volumes/Home/yasuaki/.cpan/sources/modules/03modlist.data.gz
Going to write /Volumes/Home/yasuaki/.cpan/Metadata
Running install for module DBD::mysql
Running make for C/CA/CAPTTOFU/DBD-mysql-4.006.tar.gz
Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.006.tar.gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/authors/id/C/CA/CAPTTOFU/CHECKSUMS
Checksum for /Volumes/Home/yasuaki/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.006.tar.gz ok
Scanning cache /Volumes/Home/yasuaki/.cpan/build for sizes
DBD-mysql-4.006/
DBD-mysql-4.006/ChangeLog
DBD-mysql-4.006/constants.h
DBD-mysql-4.006/dbdimp.c
DBD-mysql-4.006/dbdimp.h

【途中省略】 DBD-mysql-4.006/t/warnings.t DBD-mysql-4.006/TODO CPAN.pm: Going to build C/CA/CAPTTOFU/DBD-mysql-4.006.tar.gz I will use the following settings for compiling and testing: cflags (mysql_config) = -I/usr/include/mysql -fno-omit-frame-pointer -pipe embedded (mysql_config) = libs (mysql_config) = -pipe -L/usr/lib/mysql -lmysqlclient -lz -lm mysql_config (guessed ) = mysql_config nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (default ) = testpassword (default ) = testsocket (default ) = testuser (default ) = To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'.

【途中省略】 t/utf8................ok t/warnings............ok All tests successful, 2 tests skipped. Files=34, Tests=656, 7 wallclock secs ( 4.01 cusr + 1.21 csys = 5.22 CPU) /usr/bin/make test -- OK Running make install Installing /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bs Installing /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Installing /Library/Perl/5.8.8/darwin-thread-multi-2level/Bundle/DBD/mysql.pm Installing /Library/Perl/5.8.8/darwin-thread-multi-2level/DBD/mysql.pm Installing /Library/Perl/5.8.8/darwin-thread-multi-2level/DBD/mysql/GetInfo.pm Installing /Library/Perl/5.8.8/darwin-thread-multi-2level/DBD/mysql/INSTALL.pod Installing /usr/local/share/man/man3/Bundle::DBD::mysql.3pm Installing /usr/local/share/man/man3/DBD::mysql.3pm Installing /usr/local/share/man/man3/DBD::mysql::INSTALL.3pm Writing /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/.packlist Appending installation info to /System/Library/Perl/5.8.8/darwin-thread-multi-2level/perllocal.pod /usr/bin/make install -- OK cpan>



他に、必要なモジュールが有る場合には、

%sudo cpan install Crypt::DSA

のようにしてインストールして下さい.

Calendar

March 2024
S M T W T F S
 12
3456789
10111213141516
17181920212223
24252627282930
31  
  • Blogroll

  • Meta