perlより MySQLを使う為の DBI::mysqlの install
sorry Japanese only
最終更新日 2004/08/23
page size = Mbyte

perlベースの blog movabletypeを installしようとしたところ、setupにて以下のエラーが出てしまいました。

mt-check.cgi時のエラー

DBD::mysql

Your server does not have DBD::mysql installed, or DBD::mysql requires another module that is not installed. 
DBI and DBD::mysql are required if you want to use the MySQL database backend. 
Please consult the installation instructions for help in installing DBD::mysql.

mt-load.cgi実行時のエラー

Loading initial data into system...

An error occurred while loading data:

Unsupported driver MT::ObjectDriver::DBI::mysql: 
Can't locate DBI.pm in @INC (@INC contains: 
 /home/local/movable/extlib 
 /home/local/movable/lib 
 /usr/lib/perl5/5.6.1/i386-linux 
 /usr/lib/perl5/5.6.1 
 /usr/lib/perl5/site_perl/5.6.1/i386-linux
 /usr/lib/perl5/site_perl/5.6.1 
 /usr/lib/perl5/site_perl 
 /usr/local/lib/site_perl/5.6.1/i386-linux /usr/local/lib/site_perl/5.6.1
 /usr/local/lib/site_perl .) at /home/localhost/movabletype/lib/MT/ObjectDriver/DBI.pm line 9. 
BEGIN failed--compilation aborted at /home/local/movable/lib/MT/ObjectDriver/DBI.pm line 9. 
Compilation failed in require at /home/local/movable/lib/MT/ObjectDriver/DBI/mysql.pm line 9. 
BEGIN failed--compilation aborted at /home/local/movable/lib/MT/ObjectDriver/DBI/mysql.pm line 9. 
Compilation failed in require at (eval 3) line 1. BEGIN failed--compilation aborted at (eval 3) line 1. 

PHPベースの xoopsでは MySQLを普通に使えていたので、何が原因なのかが分かりませんでした。

perlから MySQLを使えない!ってエラーだったんですね。
検索しても、余りこのような所でつまずいている人はいないようなので、私の vine linux特有の問題なのかもしれません・・?

以下のようにして perlにて MySQLを使うためのコマンドを installすることにより、上記エラーを回避することが出来ました。

参考にさせていただいたサイトの方ありがとうございました。(順不同、敬称略)
コマンドによるMySQL管理テクニック
CPAN経由でLinuxにモジュールを組み込む
INSTALL - DBD::mysqlのインストールと構成設定の方法
mtinstall - Installing Movable Type[mtinstall-Movable Typeのインストール ]
Serian's Blog: MovableType アーカイブ
What's new? +diary (a kind of, not daily): Movable Type覚書 Archives
□ カ シ ワ ヤ □ by カ タ シ ヨ ワ カ モ シ: debian + MySQL + movable type
Movable Type 3.x 導入手順: mt-load.cgiを実行

以下が perlのモジュールの組み込み方です。
perlにて CPANの installを行う。(って言い方で良いのだと思います)
CPANとは perlへモジュールを追加するときなどに使うコマンドのことです(らしいです)
以下のような対話形式にて初期設定を行い installを行います。

まずは、どういう訳だかエラーで ftpできなかった CPANサーバーの設定を先にしておきます。

[root]# vi /usr/lib/perl5/5.6.1/CPAN/Config.pm
これの一番最後の方に
'urllist' => [q[ftp://ring.ocn.ad.jp/pub/CPAN/]],
の様な行があるので、CPANがきちんと揃っている ftpサーバーに変更しておきます。
上記アドレスには揃っていました。(けれども調子はいまいち。レスポンスが悪いです。設定が不足又は間違っている感じです)

それでは、ファイルを上書きで保存し、以下の設定を行います。

基本的に、全てリターンのデフォルト設定で OKです。

[root]# perl -MCPAN -e shell

/usr/lib/perl5/5.6.1/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] 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? [/root/.cpan] 


If you want, I can keep the source files after a build in the cpan
home directory. If you choose so then future builds will take the
files from there. If you don't want to keep them, answer 0 to the
next question.



How big should the disk cache be for keeping the build directories
with all the intermediate files?

Cache size for build directory (in MB)? [10] 


By default, each time the CPAN module is started, cache scanning
is performed to keep the cache size in sync. To prevent from this,
disable the cache scanning with 'never'.

Perform cache scanning (atstart or never)? [atstart] 


To considerably speed up the initial CPAN shell startup, it is
possible to use Storable to create a cache of metadata. If Storable
is not available, the normal index mechanism will be used.

Cache metadata (yes/no)? [yes] 


The next option deals with the charset your terminal supports. In
general CPAN is English speaking territory, thus the charset does not
matter much, but some of the aliens out there who upload their
software to CPAN bear names that are outside the ASCII range. If your
terminal supports UTF-8, you say no to the next question, if it
supports ISO-8859-1 (also known as LATIN1) then you say yes, and if it
supports neither nor, your answer does not matter, you will not be
able to read the names of some authors anyway. If you answer no, names
will be output in UTF-8.

Your terminal expects ISO-8859-1 (yes/no)? [yes] 


The CPAN module can detect when a module that which you are trying to
build depends on prerequisites. If this happens, it can build the
prerequisites for you automatically ('follow'), ask you for
confirmation ('ask'), or just ignore them ('ignore'). Please set your
policy to one of the three values.

Policy on building prerequisites (follow, ask or ignore)? [ask] 


The CPAN module will need a few external programs to work properly.
Please correct me, if I guess the wrong path for a program. Don't
panic if you do not have some of them, just press ENTER for those. To
disable the use of a download program, you can type a space followed
by ENTER.

Where is your gzip program? [/bin/gzip] 
Where is your tar program? [/bin/tar] 
Where is your unzip program? [/usr/bin/unzip] 
Where is your make program? [/usr/bin/make] 
Warning: lynx not found in PATH
Where is your lynx program? [] 
Where is your wget program? [/usr/bin/wget] 
Warning: ncftpget not found in PATH
Where is your ncftpget program? [] 
Warning: ncftp not found in PATH
Where is your ncftp program? [] 
Where is your ftp program? [/usr/bin/ftp] 
What is your favorite pager program? [/usr/bin/less] 
What is your favorite shell? [/bin/bash] 


Every Makefile.PL is run by perl in a separate process. Likewise we
run 'make' and 'make install' in processes. If you have any
parameters (e.g. PREFIX, LIB, UNINST or the like) you want to pass
to the calls, please specify them here.

If you don't understand this question, just press ENTER.

Parameters for the 'perl Makefile.PL' command?
Typical frequently used settings:

    POLLUTE=1        increasing backwards compatibility
    LIB=~/perl       non-root users (please see manual for more hints)

Your choice:  [] POLLUTE=1
Parameters for the 'make' command?
Typical frequently used setting:

    -j3              dual processor system

Your choice:  [] 
Parameters for the 'make install' command?
Typical frequently used setting:

    UNINST=1         to always uninstall potentially conflicting files

Your choice:  [] 


Sometimes you may wish to leave the processes run by CPAN alone
without caring about them. As sometimes the Makefile.PL contains
question you're expected to answer, you can set a timer that will
kill a 'perl Makefile.PL' process after the specified time in seconds.

If you set this value to 0, these processes will wait forever. This is
the default and recommended setting.

Timeout for inactivity during Makefile.PL? [0]      


If you're accessing the net via proxies, you can specify them in the
CPAN configuration or via environment variables. The variable in
the $CPAN::Config takes precedence.

Your ftp_proxy?  
Your http_proxy? 
Your no_proxy?  
You have no /root/.cpan/sources/MIRRORED.BY
  I'm trying to fetch one
LWP not available

  Please, install Net::FTP as soon as possible. CPAN.pm installs it for you
  if you just type
      install Bundle::libnet


Trying with "/usr/bin/wget -O -" to get
    ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY
--23:20:18--  ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY
           => `-'
ftp.perl.org をDNSに問いあわせています... 完了しました。
ftp.perl.org[203.174.65.13]:21 に接続しています... 接続しました。
anonymous としてログインしています... ログインしました!
==> SYST ... 完了しました。    ==> PWD ... 完了しました。
==> TYPE I ... 完了しました。  ==> CWD /pub/CPAN ... 完了しました。
==> PORT ... 完了しました。    ==> RETR MIRRORED.BY ... 
サーバの応答にエラーがあるので、接続を終了します。
再試行しています。

と、私の場合は、先に ftpサーバーの設定を行わなかったので、上記のように timeout errorとなってしまいました。
(他のサイトを見ると、どこを ftpサーバーにするかを聞いてくるようなことが書いてあるんだけど?)

何度もやり直すときは、ftpサーバーより中途半端にファイルが転送されていたりするので、/root/.cpanディレクトリー以下を全削除してからやり直す方が良いようです。

[root]# cd /root/.cpan
[root]# rm -r -f *

で、もう一度同じ事をやると、初期設定は終了しているので一気にプロンプトが出ます。
順次必要なコマンドを installしていきます。
[root@vine1 root]# perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.76)
ReadLine support enabled

cpan> install Jcode
cpan> install DB_File
cpan> install DBI
cpan> install DBD::mysql
すぐ終わるような書き方をしていますが、コンパイルなどをやるのでそれぞれが時間かかります。(と言っても数分?)

最後の DBD::mysqlは MySQLへ接続しに行きますから、MySQLの rootに passwordをかけてあると以下のようなエラーが出ます。

t/10dsnlist........DBI connect('test','',...) failed: Access denied for user: 'root@localhost' (Using password: NO) at t/10dsnlist.t line 45
Cannot connect: Access denied for user: 'root@localhost' (Using password: NO)
        Either your server is not up and running or you have no
        permissions for acessing the DSN DBI:mysql:test.
        This test requires a running server and write permissions.
        Please make sure your server is running and you have
        permissions, then retry.
t/10dsnlist........dubious                                                   

MySQLの rootの passwordを以下のコマンドで無しにしてからもう一度 install DBD:mysqlを実行しましょう。

[root]# mysqladmin -u root -p password ""
その他、途中エラーを回避するため色々なコマンドを実行しました。

cpan> install Bundle::CPAN
open> install Bundle::libnet
などを行う必要があるかもしれません。

29054
戻る