UJP - 技術情報1

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

DBIとDBD::mysqlをインストールするforCentOS5.1

DBIとDBD::mysqlをインストールするforCentOS5.1


0.改訂履歴

  • 2008.07.14 新規作成

1.はじめに

 このドキュメントでは,PerlのモジュールであるDBIとDBDをインストールする手順を説明する.

 DBIはSQLをパースするだけの抽象クラスとして提供されるモジュールであり,汎用的なデータベースアクセスクラスとして提供され る. 一方,DBDは,DBIから渡されたSQL文を実際にデータベースへ接続して発行するためのクラスとして提供され,今回の環境ではMySQLに接続 するため,DBD::mysqlモジュールをインストールする事となる.

 DBD::mysqlはそれまでに準備されている環境によって,インストールが失敗する事もあるが,その場合テストが成功する様にソースからインストールする.

2.CPANモジュールからDBIをインストールする

  • まずは,事前にrootユーザとしてログインしておく.
  • CPANモジュールを起動する.
    • この作業の前提として,CPANモジュールの基本的な設定は完了しておる事を前提とする.
[root@mars ujpadmin]# perl -MCPAN -e shell
CPAN: File::HomeDir loaded ok (v0.80)

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

cpan[1]>
  • インストールを行う.
cpan[1]> install DBI 
CPAN: Storable loaded ok (v2.15)
Going to read /root/.cpan/Metadata
Database was generated on Wed, 09 Jul 2008 21:02:57 GMT
Running install for module 'DBI'
Running make for T/TI/TIMB/DBI-1.605.tar.gz
CPAN: LWP::UserAgent loaded ok (v2.033)
CPAN: Time::HiRes loaded ok (v1.86)
Fetching with LWP:

〜略〜

Installing /usr/bin/dbiproxy
Installing /usr/bin/dbilogstrip
Installing /usr/bin/dbiprof
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perll
ocal.pod TIMB/DBI-1.605.tar.gz
/usr/bin/make install -- OK

cpan[2]>
  • DBIの場合,特に問題なくインストールされるはず.
  • 念のため,おまじないとして再度インストールを実行する.
cpan[2]> install DBI 
DBI is up to date (1.605).

cpan[3]>
  • アップデートモジュールは無いと表示されているので,インストール完了.

3.CPANモジュールからDBD::mysqlをインストールする.

  • DBIと同じ様に,CPANモジュールでDBD::mysqlをインストールする.
cpan[3]> install DBD::mysql 
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.007.tar.gz
Fetching with LWP:
ftp://ftp.kddilabs.jp/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.007.tar.gz
Fetching with LWP:
ftp://ftp.kddilabs.jp/CPAN/authors/id/C/CA/CAPTTOFU/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.007.tar.gz ok
DBD-mysql-4.007/
DBD-mysql-4.007/ChangeLog
DBD-mysql-4.007/constants.h
DBD-mysql-4.007/dbdimp.c

〜略〜

Test Summary Report
-------------------
t/80procs (Wstat: 65280 Tests: 4 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 29 tests but ran 4.
Files=34, Tests=662, 3 wallclock secs ( 0.15 usr 0.04 sys + 2.07 cusr 0.23 csys =
 2.49 CPU)
Result: FAIL
Failed 1/34 test programs. 0/662 subtests failed.
make: *** [test_dynamic] エラー 255
CAPTTOFU/DBD-mysql-4.007.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports CAPTTOFU/DBD-mysql-4.007.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
CAPTTOFU/DBD-mysql-4.007.tar.gz : make_test NO

cpan[4]>
  • エラーが出る.
    • 環境によっては,出ない場合もある.これが難しい.
  • これは,DBDのインストールテストが失敗している事が原因である.
  • DBDのテストを行う為には,テスト用の接続ユーザ必要となる.
  • いったんCPANモジュールを終了する.
cpan[4]> quit 
Lockfile removed.
[root@mars ujpadmin]#
  • いったん終了した.

4.ソースコードからDBD::mysqlをインストールする

  • DBD::mysqlのモジュールは,CPANモジュールでインストールを実行した際に,ダウンロードされている.
  • ダウンロードされているファイルをを確認する.
[root@mars ujpadmin]# ls -la /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-
mysql-4.007.tar.gz
-rw-r--r-- 1 root root 123516 Jul 11 15:49 /root/.cpan/sources/authors/id/C/CA/
CAPTTOFU/DBD-mysql-4.007.tar.gz
[root@mars ujpadmin]#
  • アーカイブを展開して中身を確認する.
[root@mars ujpadmin]# tar xfz /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-
mysql-4.007.tar.gz
[root@mars ujpadmin]# cd DBD-mysql-4.007/
[root@mars DBD-mysql-4.007]# ls -la
total 336
drwxr-xr-x 5 501 501 4096 May 12 00:54 .
drwxr-x--- 21 root root 4096 Jul 14 11:41 ..
-rwxr-xr-x 1 501 501 56147 May 12 00:54 ChangeLog
-rwxr-xr-x 1 501 501 29283 May 12 00:54 INSTALL.html
-rw-r--r-- 1 501 501 1117 May 12 00:24 MANIFEST
-rw-r--r-- 1 501 501 41 Jan 4 2007 MANIFEST.SKIP
-rw-r--r-- 1 501 501 380 May 12 00:54 META.yml
-rwxr-xr-x 1 501 501 24189 May 12 00:52 Makefile.PL
-rw-r--r-- 1 501 501 713 Dec 24 2006 Makefile.PL.embedded
-rwxr-xr-x 1 501 501 2781 Jan 7 2007 README
-rw-r--r-- 1 501 501 896 Dec 24 2006 TODO
-rwxr-xr-x 1 501 501 1948 Dec 6 2007 constants.h
-rwxr-xr-x 1 501 501 128042 Apr 29 08:36 dbdimp.c
-rwxr-xr-x 1 501 501 10173 Apr 29 08:36 dbdimp.h
drwxr-xr-x 2 501 501 4096 May 12 00:54 eg
drwxr-xr-x 4 501 501 4096 May 12 00:54 lib
-rwxr-xr-x 1 501 501 1709 Jan 4 2007 myld
-rwxr-xr-x 1 501 501 17286 Apr 29 08:36 mysql.xs
drwxr-xr-x 2 501 501 4096 May 12 00:54 t

[root@mars DBD-mysql-4.007]#
  • Perl Makeを実行する.
[root@mars DBD-mysql-4.007]# perl Makefile.PL


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'ujpadmin' 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 'ujpadmin'@'localhost' identified by 's3
kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.pl --testuser=username

I will use the following settings for compiling and testing:

cflags (mysql_config) = -I/usr/include/mysql -g -pipe -march=i386 -mcpu
=i686
embedded (mysql_config) =
libs (mysql_config) = -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -
lnsl -lm
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (default ) =
testsocket (default ) =
Use of uninitialized value in printf at Makefile.PL line 171, <PIPE> line 93.
testuser ( ) = ujpadmin


To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.

Checking if your kit is complete...
Looks good
Multiple copies of Driver.xst found in: /usr/lib/perl5/site_perl/5.8.8/i386-
linux-thread-multi/auto/DBI/ /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-
multi/auto/DBI/ at Makefile.PL line 759
Using DBI 1.605 (for perl 5.008008 on i386-linux-thread-multi) installed in /usr
/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::mysql
[root@mars DBD-mysql-4.007]#
  • とりあえず問題なく完了している模様.
  • makeを実行する.
[root@mars DBD-mysql-4.007]# make
cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm
gcc -c -I/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI -I/usr
/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector -
-param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-
tables -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -D_REENTRANT -D_GNU_SOURCE -fno-strict-
aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_
SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_
FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -
march=i386 -mtune=generic -fasynchronous-unwind-tables -DVERSION=\"4.007\" -
DXS_VERSION=\"4.007\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE
" dbdimp.c
dbdimp.c: In function 'parse_params':
dbdimp.c:464: warning: implicit declaration of function 'parse_number'
dbdimp.c: In function 'dbd_discon_all':
dbdimp.c:1948: warning: unused variable 'imp_xxh'
/usr/bin/perl -p -e "s/~DRIVER~/mysql/g" /usr/lib/perl5/site_perl/5.8.8/i386-
linux-thread-multi/auto/DBI/Driver.xst > mysql.xsi
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.8.
8/ExtUtils/typemap mysql.xs > mysql.xsc && mv mysql.xsc mysql.c
Warning: duplicate function definition 'do' detected in mysql.xs, line 225
Warning: duplicate function definition 'rows' detected in mysql.xs, line 612
gcc -c -I/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI -I/usr
/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector -
-param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-
tables -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -D_REENTRANT -D_GNU_SOURCE -fno-strict-
aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_
SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_
FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -
march=i386 -mtune=generic -fasynchronous-unwind-tables -DVERSION=\"4.007\" -
DXS_VERSION=\"4.007\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE
" mysql.c
mysql.xs: In function 'XS_DBD__mysql__db_do':
mysql.xs:239: warning: unused variable 'statement_ptr'
mysql.xs: In function 'XS_DBD__mysql__st_more_results':
mysql.xs:550: warning: implicit declaration of function 'mysql_st_next_results'
mysql.xs:549: warning: unused variable 'retval'
mysql.xs: In function 'XS_DBD__mysql__GetInfo_dbd_mysql_get_info':
mysql.xs:686: warning: implicit declaration of function 'is_prefix'
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
/usr/bin/perl myld gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -
fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=
generic -fasynchronous-unwind-tables -L/usr/local/lib dbdimp.o mysql.o -o blib/
arch/auto/DBD/mysql/mysql.so \
-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm \

chmod 755 blib/arch/auto/DBD/mysql/mysql.so
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Manifying blib/man3/DBD::mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Bundle::DBD::mysql.3pm
[root@mars DBD-mysql-4.007]#
  • 問題なく完了している.
  • テストを実行する.
[root@mars DBD-mysql-4.007]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
t/00base....................ok
t/10connect.................ok
t/20createdrop..............ok
t/25lockunlock..............ok
t/29warnings................ok
t/30insertfetch.............ok
t/31insertid................ok
t/32insert_error............ok
t/35limit...................ok
t/35prepare.................ok
t/40bindparam...............ok
t/40bindparam2..............ok
t/40blobs...................ok
t/40catalog.................ok
t/40keyinfo.................ok
t/40listfields..............ok
t/40nulls...................ok
t/40numrows.................ok
t/40server_prepare..........ok
t/40server_prepare_error....ok
t/40types...................ok
t/41bindparam...............ok
t/41blobs_prepare...........ok
t/42bindparam...............ok
t/50chopblanks..............ok
t/50commit..................ok
t/55utf8....................ok
t/60leaks...................skipped: Skip $ENV{SLOW_TESTS} is not set
t/65types...................ok
t/70takeimp.................ok
t/71impdata.................ok
t/75supported_sql...........ok
t/76multi_statement.........ok
t/80procs...................1/29 DBD::mysql::db do failed: alter routine command
denied to user ''@'localhost' for routine 'test.testproc' at t/80procs.t line 41.
DBD::mysql::db do failed: alter routine command denied to user ''@'localhost'
for routine 'test.testproc' at t/80procs.t line 41.
# Looks like you planned 29 tests but only ran 2.
# Looks like your test died just after 2.
t/80procs................... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 27/29 subtests

Test Summary Report
-------------------
t/80procs (Wstat: 65280 Tests: 2 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 29 tests but ran 2.
Files=34, Tests=660, 3 wallclock secs ( 0.14 usr 0.05 sys + 2.05 cusr 0.26
csys = 2.50 CPU)
Result: FAIL
Failed 1/34 test programs. 0/660 subtests failed.
make: *** [test_dynamic] Error 255

[root@mars DBD-mysql-4.007]#
  • テストがエラーとなってしまう.
  • 無視してインストールしてみる.
[root@mars DBD-mysql-4.007]# make install
Files found in blib/arch: installing files in blib/lib into architecture
dependent library tree
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/mysql
/mysql.so
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/mysql
/mysql.bs
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Bundle/DBD/
mysql.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/mysql.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/mysql/
INSTALL.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/mysql/
GetInfo.pm
Installing /usr/share/man/man3/DBD::mysql.3pm
Installing /usr/share/man/man3/Bundle::DBD::mysql.3pm
Installing /usr/share/man/man3/DBD::mysql::INSTALL.3pm
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/mysql/.
packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/
perllocal.pod

[root@mars DBD-mysql-4.007]#
  • インストールは,問題なく完了.
  • DBIの時と同じ様に,CPANモジュールから再度インストールしてみる.
cpan[1]> install DBD::mysql
CPAN: Storable loaded ok (v2.06)
Going to read /root/.cpan/Metadata
Database was generated on Sun, 13 Jul 2008 23:02:48 GMT
DBD::mysql is up to date (4.007).

cpan[2]>
  • 問題なく完了している.

5.DBD::mysqlのmake testで合格させる

  • これまでの手順では,make testのフェーズでエラーが出たままとなっている.
  • perl Makefile.PL時のヘルプを確認する.
[root@mars DBD-mysql-4.007]# perl Makefile.PL -h
Usage: perl Makefile.PL [options]

Possible options are:

--cflags=<flags> Use <flags> for running the C compiler; defaults
to the value of "mysql_config --cflags" or a guessed
value
--libs=<libs> Use <libs> for running the linker; defaults
to the value of "mysql_config --libs" or a gussed
value
--embedded=<libs> Build embedded version of DBD and use <libs> for this;
defaults to the value of "mysql_config --embedded"
(default: off)
--testdb=<db> Use the database <db> for running the test suite;
defaults to test
--testuser=<user> Use the username <user> for running the test suite;
defaults to no username
--testpassword=<pwd> Use the password <pwd> for running the test suite;
defaults to no password
--testhost=<host> Use <host> as a database server for running the
test suite; defaults to localhost.
--testport=<port> Use <port> as the port number of the database;
by default the port number is choosen from the
mysqlclient library
--mysql_config=<path> Specify <path> for mysql_config script
(Not supported on Win32)
--nocatchstderr Supress using the "myld" script that redirects
STDERR while running the linker.
--nofoundrows Change the behavior of $sth->rows() so that it
returns the number of rows physically modified
instead of the rows matched
--ps-protocol Toggle the use of driver emulated prepared statements
prepare, requires MySQL server >= 4.1.3 for
server side prepared statements, off by default
--force-embedded Force to build embedded version of driver
--ssl Enable SSL support
--help Print this message and exit

All options may be configured on the command line. If they are
not present on the command line, then mysql_config is called (if
it can be found):

mysql_config --cflags
mysql_config --libs
mysql_config --embedded
mysql_config --testdb

and so on. See the INSTALL.html file for details.
[root@mars DBD-mysql-4.007]#
  • ここではテスト用データベースへの接続の為に必要なオプションの指定方法と,環境設定を調べる為のコマンドが記述されている.
  • まず,MySQLの環境を調べる必要がある.
  • mysql_configコマンドにて,設定内容を確認する.
  • まずは,コマンドを探す.
[root@mars DBD-mysql-4.007]# locate mysql_config
/usr/bin/mysql_config
[root@mars DBD-mysql-4.007]#
  • パスは通っている模様.
  • コマンドを実行して,環境を確認する.
[root@mars DBD-mysql-4.007]# mysql_config
Usage: /usr/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686]
--include [-I/usr/include/mysql]
--libs [-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm]
--libs_r [-L/usr/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -l
nsl -lm -lpthread]
--socket [/var/lib/mysql/mysql.sock]
--port [3306]
--version [5.0.27]
--libmysqld-libs [-L/usr/lib/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm
 -lpthread -lrt]
[root@mars DBD-mysql-4.007]#
  • 特に,ライブラリ部分が正しく指定されているか,確認する必要がある.
  • サンプルとして,MySQLのクライアントライブラリが入っているか確認する.
[root@mars DBD-mysql-4.007]# ls -la /usr/lib/mysql/
total 16164
drwxr-xr-x 2 root root 4096 Dec 19 2006 .
drwxr-xr-x 121 root root 61440 Dec 19 2006 ..
-rw-r--r-- 1 root root 27974 Oct 21 2006 libdbug.a
-rw-r--r-- 1 root root 416488 Oct 21 2006 libheap.a
-rw-r--r-- 1 root root 57872 Oct 21 2006 libmygcc.a
-rw-r--r-- 1 root root 1832838 Oct 21 2006 libmyisam.a
-rw-r--r-- 1 root root 587234 Oct 21 2006 libmyisammrg.a
-rw-r--r-- 1 root root 4956358 Oct 21 2006 libmysqlclient.a
-rwxr-xr-x 1 root root 923 Oct 21 2006 libmysqlclient.la
-rw-r--r-- 1 root root 4978414 Oct 21 2006 libmysqlclient_r.a
-rwxr-xr-x 1 root root 969 Oct 21 2006 libmysqlclient_r.la
-rw-r--r-- 1 root root 1657008 Oct 21 2006 libmystrings.a
-rw-r--r-- 1 root root 922784 Oct 21 2006 libmysys.a
-rw-r--r-- 1 root root 41910 Oct 21 2006 libvio.a
-rw-r--r-- 1 root root 165448 Oct 21 2006 libz.a
-rwxr-xr-x 1 root root 789 Oct 21 2006 libz.la
-rw-r--r-- 1 root root 738080 Oct 21 2006 mysqld.sym
[root@mars DBD-mysql-4.007]#
  • --libオプションで指定してあるディレクトリにライブラリが存在している事が確認できた.
  • 次にDBDライブラリが,MySQLに接続する際のアカウント等を作成する.
  • 先の手順の中で,perl Makefile.PLを実行した際に,次の様なメッセージが表示されている.
[root@mars DBD-mysql-4.007]# perl Makefile.PL


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'ujpadmin' 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 'ujpadmin'@'localhost' identified by 's
3kr1t';


You can also optionally set the user to run 'make test' with:

perl Makefile.pl --testuser=username



〜つづく〜
  • testデータベースにアクセスできるujpadminユーザの作成が必要と書いてある.
    • ちなみに,ここで表示してあるパスワードは,いつも同じ物が表示される.
      • よって,試用が終わったらこのアカウントは削除する.
  • MySQLサーバに接続する.
[root@mars DBD-mysql-4.007]# mysql -uroot -ppassword
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 117516 to server version: 5.0.27-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
  • データベースを確認する.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql>
  • テスト用のtestデータベースが存在している事が確認できた.
  • ユーザを作成する.
mysql> grant all privileges on test.* to 'ujpadmin'@'localhost' identified by 's
3kr1t';

Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@mars DBD-mysql-4.007]#
  • 作成したユーザで接続し,testデータベースにテーブルの作成ができるか確認する.
[root@mars DBD-mysql-4.007]# mysql -uujpadmin -ps3kr1t
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 117517 to server version: 5.0.27-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test
Database changed
mysql> create table deleteMe (a int);
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@mars DBD-mysql-4.007]#
  • 問題なく確認できた.
  • 先ほど一度DBD::mysqlをインストールしているので,いったん全て削除する.
[root@mars DBD-mysql-4.007]# make realclean
rm -f \
*.a core \
core.[0-9] blib/arch/auto/DBD/mysql/extralibs.all \
core.[0-9][0-9] mysql.bso \
pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \
mysql.x mysql.bs \
perl tmon.out \
*.o pm_to_blib \
blib/arch/auto/DBD/mysql/extralibs.ld mysql.c \
blibdirs.ts core.[0-9][0-9][0-9][0-9][0-9] \
*perl.core core.*perl.*.? \
Makefile.aperl mysql.def \
perl core.[0-9][0-9][0-9] \
mon.out libmysql.def \
perlmain.c perl.exe \
so_locations mysql.exp
rm -rf \
*.xsi blib
mv Makefile Makefile.old > /dev/null 2>&1
rm -f \
dbdimp.o mysql.o Makefile.old \
Makefile
rm -rf \
t/mysql.mtest DBD-mysql-4.007
[root@mars DBD-mysql-4.007]#
  • perl Makefil.PLを実行する.
  • このときに,データベースへ接続する為のユーザ&パスワードを指定する.
[root@mars DBD-mysql-4.007]# perl Makefile.PL --testuser=ujpadmin --
testpassword=s3kr1t

I will use the following settings for compiling and testing:

cflags (mysql_config ) = -I/usr/include/mysql -g -pipe -march=i386 -
mcpu=i686
embedded (mysql_config ) =
libs (mysql_config ) = -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -
lnsl -lm
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (User's choice) = s3kr1t
testsocket (default ) =
testuser (User's choice) = ujpadmin

To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.

Checking if your kit is complete...
Looks good
Multiple copies of Driver.xst found in: /usr/lib/perl5/site_perl/5.8.0/i386-
linux-thread-multi/auto/DBI/ /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-
multi/auto/DBI/ at Makefile.PL line 759
Using DBI 1.605 (for perl 5.008 on i386-linux-thread-multi) installed in /usr/
lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::mysql
[root@mars DBD-mysql-4.007]#
  • 問題なく完了した模様.
  • makeを行う.
[root@mars DBD-mysql-4.007]# make
cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod

〜略〜

chmod 755 blib/arch/auto/DBD/mysql/mysql.so
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Manifying blib/man3/DBD::mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Bundle::DBD::mysql.3pm

[root@mars DBD-mysql-4.007]#
  • make testを実行する.
[root@mars DBD-mysql-4.007]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
t/00base....................ok
t/10connect.................ok
t/20createdrop..............ok
t/25lockunlock..............ok
t/29warnings................ok
t/30insertfetch.............ok
t/31insertid................ok
t/32insert_error............ok
t/35limit...................ok
t/35prepare.................ok
t/40bindparam...............ok
t/40bindparam2..............ok
t/40blobs...................ok
t/40catalog.................ok
t/40keyinfo.................ok
t/40listfields..............ok
t/40nulls...................ok
t/40numrows.................ok
t/40server_prepare..........ok
t/40server_prepare_error....ok
t/40types...................ok
t/41bindparam...............ok
t/41blobs_prepare...........ok
t/42bindparam...............ok
t/50chopblanks..............ok
t/50commit..................ok
t/55utf8....................ok
t/60leaks...................skipped: Skip $ENV{SLOW_TESTS} is not set
t/65types...................ok
t/70takeimp.................ok
t/71impdata.................ok
t/75supported_sql...........ok
t/76multi_statement.........ok
t/80procs...................ok
All tests successful.
Files=34, Tests=687, 4 wallclock secs ( 0.34 usr 0.09 sys + 3.87 cusr 0.35
csys = 4.65 CPU)
Result: PASS
[root@mars DBD-mysql-4.007]#
  • 今度は,問題なく完了している.
[root@mars DBD-mysql-4.007]# make install
Files found in blib/arch: installing files in blib/lib into architecture
dependent library tree
Writing /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/DBD/mysql/.
packlist
Appending installation info to /usr/lib/perl5/5.8.0/i386-linux-thread-multi/
perllocal.pod
[root@mars DBD-mysql-4.007]#
  • 問題なく完了.
  • これで安心して利用できる.


広告スペース
Google