Installing DBD::mysql
Updated at 8 Jan 2013
If you tried to run installing DBD::mysql like this entry, please see comments to the end.
Installing DBD::mysql was long way to me.
I have already installed MySQL and DBI like this.
I used rpms via Download MySQL Community Server
$ rpm -qa | grep -i mysql MySQL-shared-compat-5.5.29-1.linux2.6.x86_64 MySQL-server-5.5.29-1.linux2.6.x86_64 MySQL-devel-5.5.29-1.linux2.6.x86_64 MySQL-client-5.5.29-1.linux2.6.x86_64
DBI is below.
$ cpanm DBI
Okay, I will show you my steps.
First of all, I got source code of DBD::mysql from github.
$ git clone https://github.com/CaptTofu/DBD-mysql.git $ cd DBD-mysql $ perl Makefile.PL $ make
I saw an error in runing make.
$ make /usr/bin/ld: cannot find -lmysqlclient
hmm. I was looking for resolving this error. I got a hint which add libs option.
$ perl Makefile.PL --libs="-L/usr/lib64/mysql -lmysqlclient"
Okay, I ran make successfully.
Next, I will run make test
.
$ make test t/00base.t ........................... 1/6 Bailout called. Further testing stopped: Unable to load DBD::mysql# Failed test 'use DBD::mysql;'
# at t/00base.t line 21.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/home/shigeta/tmp/DBD-mysql/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: /home/shigeta/tmp/DBD-mysql/blib/arch
/auto/DBD/mysql/mysql.so: undefined symbol: pthread_mutex_trylock at /home/shigeta/perl5/perlbrew/perls/perl-5.12.5/lib/5.12.5/x86_64-linux/DynaLoade
r.pm line 200.
hmm. I read pod again. I found this. I tried to run below.
$ mysql_config --libs -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl
Ah, I need to add -pthread option. So, I tried to run like below.
$ perl Makefile.PL --libs="-L/usr/lib64/mysql -lmysqlclient -lpthread"
Grrr, I saw an error again.
$ make test t/80procs.t .......................... 1/29 DBD::mysql::db do failed: alter routine command denied to user ''@'localhost' for routine 'test.testproc' at t/80procs.t line 41.
Okay, I needed to add an option, --testuser=root
.
$ perl Makefile.PL --libs="-L/usr/lib64/mysql -lmysqlclient -lpthread" --testuser=root $ make $ make test
Finally, I installed DBD::mysql successfully like below.
$ git clone https://github.com/CaptTofu/DBD-mysql.git $ cd DBD-mysql $ perl Makefile.PL --libs="-L/usr/lib64/mysql -lmysqlclient -lpthread" --testuser=root $ make $ make test $ make install
Yay :)
Anyway, DBD::mysql revision was below.
$ git log --pretty=oneline -1 6e75c2e30ffbc2a6cb2554a7459b929e1f44ad1e Merge pull request #31 from 9re/master
You should be able to install DBD::mysql via:
$ cpanm -look DBD::mysql
$ perl Makefile.PL --mysql_config=/path/to/mysql_config
$ make && make install
Specifying the correct mysql_config should give DBD::mysql all the valid defaults.
Posted by: lestrrat | 30 December 2012 at 02:55 AM
Thank you, lestrrat!
Posted by: Takatsugu Shigeta | 07 January 2013 at 09:41 PM
Probably, the cause is from my environment :(
$ mysql_config --libs
-L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl
But libmysqlclient.a is in following directory.
$ ls -1 -F /usr/lib64/mysql/
libmygcc.a
libmysqlclient.a
libmysqlclient_r.a@
libmysqlservices.a
libtcmalloc_minimal.so*
plugin/
Thank you for your help, lestrrat :)
Posted by: Takatsugu Shigeta | 07 January 2013 at 09:55 PM