cpanmでDBD::mysqlをインストール。
Catalystの勉強で、O/Rマッパーモデルのクラスを作るヘルパースクリプト実行時にエラーが発生したのでメモ。
% cpanm Catalyst::Model::DBIC::Schema
- ヘルパースクリプトでテーブルクラスを作ります。
% ./myapp_create.pl model MyappDB DBIC::Schema Myapp::Schema create=static dbi:mysql:myapp username password : : 「DBIx::Class::Schema::Loader」がないというエラーが出ます。
- 「DBIx::Class::Schema::Loader」をインストールします。
% cpanm DBIx::Class::Schema::Loader
- 再度ヘルパースクリプトでテーブルクラスを作ります。
% ./myapp_create.pl model MyappDB DBIC::Schema Myapp::Schema create=static dbi:mysql:myapp username password : : 今度は「DBD::mysql」がないというエラーが出ます。
- 「DBD::mysql」をインストールします。
% cpanm DBD::mysql : : PLEASE NOTE: For 'make test' to run properly, you must ensure that the database user 'koba04' 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. とエラーが発生します。
- cpanmでインストールしようとしたDBD::mysqlモジュールの場所に移動して下記を実行します。
% cd ~/.cpanm/latest-build/DBD-mysql-4.016 % perl Makefile.PL --testuser='username' --testpassword='password' : Can't exec "mysql_config": No such file or directory at Makefile.PL line 82.
- とすると、今後はmysql_cofingが見つからないと言われました。調べてみるとインストールされているMySQLではmysql_configがmysql_config5としてインストールされていたので、シンボリックリンクを設定します。(MySQLはmacportsでインストールしました)
% sudo ln -s /opt/local/bin/mysql_config5 /opt/local/bin/mysql_config
- として再度試してみると今度はエラーが出ないはずですので、そのままインストールします。
% perl Makefile.PL --testuser='username' --testpassword='password' % make % make test % make install
- 再度ヘルパースクリプトを実行するとうまくいきました!
% cd Myapp/script % ./myapp_create.pl model MyappDB DBIC::Schema Myapp::Schema create=static dbi:mysql:myapp username password exists "/Users/koba04/catalyst/Myapp/script/../lib/Myapp/Model" exists "/Users/koba04/catalyst/Myapp/script/../t" Dumping manual schema for Myapp::Schema to directory /Users/koba04/catalyst/Myapp/script/../lib ... Schema dump completed. created "/Users/koba04/catalyst/Myapp/script/../lib/Myapp/Model/MyappDB.pm" created "/Users/koba04/catalyst/Myapp/script/../t/model_MyappDB.t"