解决无法安装DBD::mysql模块
转载自:http://www.php-oa.com/2010/10/29/perl-mysql-%e7%9a%84%e6%a8%a1%e5%9d%97%e4%b8%8d%e8%83%bd%e5%ae%89%e8%a3%85%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95.html
我们最常用的 DBD::mysql 模块,我发现是难住很多人的地方.因为安装老是失败,下面我介绍一下解决方法,比如我使用 cpanm 安装,有时就出 /home/nue2501j/work/DBD-mysql-4.010/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: DBIc_TRACE_LEVEL at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
如下
1
|
cpanm DBD::mysql |
出错
1
2
3
4
5
6
7
|
# Tried to use 'DBD::mysql'. # Error: Can't load '/home/nue2501j/work/DBD-mysql-4.010/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: /home/nue2501j/work/DBD-mysql-4.010/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: DBIc_TRACE_LEVEL at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230. # at (eval 4) line 2 # Compilation failed in require at (eval 4) line 2. # BEGIN failed--compilation aborted at (eval 4) line 2. FAILED--Further testing stopped: Unable to load DBD::mysql make: *** [test_dynamic] Error 9 |
解决方法
1
2
3
4
5
6
7
|
$ sudo perl -MCPAN -e shell cpan> install Bundle::DBD::mysql /usr/bin/make -- OK /usr/bin/make test -- OK /usr/bin/make install -- OK cpan> install DBD::mysql DBD::mysql is up to date. |
另外注意,当你以前就在服务器上跑了一个 MYSql 的话,然后设置密码后在安装这个模块,99%会失败,需要关掉 mysqld 的服务
FAQ 2 出现 make: *** [dbdimp.o] Error 1 的错误
1
|
$ yum install mysql-devel |
FAQ3:出现如下错误,提示 undefined symbol: is_prefix .
# Error: Can't load '/root/.cpan/build/DBD-mysql-4.020/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: /root/.cpan/build/DBD-mysql-4.020/blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: is_prefix at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
这时需要修改文件.
你下载好模块解压进入后(一般都是/root/.cpan/build/DBD-mysql-4.020该目录),编辑 mysql.c 这个文件
修改
1
2
3
4
|
using_322=is_prefix(mysql_get_server_info(imp_dbh->pmysql), "3.22" ); retsv = newSVpv(!using_322 ? "`" : " " , 1); break; |
修改成
1
2
3
4
5
|
/* using_322=is_prefix(mysql_get_server_info(imp_dbh->pmysql), "3.22" );*/ using_322 = ((strncmp(mysql_get_server_info(imp_dbh->pmysql), "3.22" ,4) == 0) ? 1 : 0 ); retsv = newSVpv(!using_322 ? "`" : " " , 1); break; |