OSX v10.6.6上DBD :: MySQL的安装错误

时间:2011-01-27 20:59:36

标签: mysql perl osx-snow-leopard dbi dbd

我试图让DBD :: MySQL在Snow Leopard(v10.6.6)上运行。操作系统附带的默认Perl版本是v5.10.0。由于我已经阅读了64位,我继续下载并安装了64位版本的MySQL(mysql-5.5.8-osx10.6-x86_64)。

安装和设置MySQL顺利进行,here's my config and version number for reference

我使用CPAN下载DBI和DBD :: MySQL驱动程序。然后我:

  • 已安装的DBI
  • 设置Makefile.PL
  • 从命令行
  • 执行 make 命令

Makefile.PL表示将使用以下设置进行编译和测试:

I will use the following settings for compiling and testing:

  cflags        (mysql_config ) = -I/usr/local/mysql/include  -Os -g -fno-common -fno-strict-aliasing -arch x86_64
  embedded      (mysql_config ) = 
  libs          (mysql_config ) = -L/usr/local/mysql/lib -lmysqlclient   -lpthread
  mysql_config  (guessed      ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  ssl           (guessed      ) = 0
  testdb        (default      ) = test
  testhost      (default      ) = 
  testpassword  (User's choice) = r00t!
  testsocket    (default      ) = 
  testuser      (User's choice) = root

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

Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 907
Using DBI 1.616 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/
Writing Makefile for DBD::mysql

在尝试运行 make test 之前,一切似乎都很顺利:

t/00base....................NOK 2/6#     Tried to use 'DBD::mysql'.          
#     Error:  Can't load '/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.16.dylib
#   Referenced from: /Users/swm/.cpan/build/DBD-mysql-4.018-Pnd2qz/blib/arch/auto/DBD/mysql/mysql.bundle
#   Reason: image not found at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207.
#  at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 9

它失败了,因为它似乎找不到DBD的mysql.bundle。有人遇到过这个问题吗?或者可以指出我正确的方向下一步尝试什么?我需要DBI / DBD :: MySQL来完成我的新工作,我正忙着寻找解决方案。

非常感谢提前。

6 个答案:

答案 0 :(得分:14)

通过在/ usr / lib /“中放置符号链接到/usr/local/mysql-5.5.8-osx10.6-x86_64/lib,我遇到了”未加载库:libmysqlclient.16.dylib“的问题/libmysqlclient.16.dylib

答案 1 :(得分:1)

我解决了相同或类似的问题。不知何故,我可以使用cpan构建和测试DBD :: mysql但是当我尝试在脚本中使用它时,它会说像

dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
  Expected in: flat namespace

显然,它是a 64-bit vs 32-bit issue.

安装fink dbd-mysql-pm5100 package使其工作虽然花了很长时间。我还删除了cpan安装的版本:

sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql
sudo rm -rf /Library/Perl/5.10.0/darwin-thread-multi-2level/DBD/mysql.pm 

答案 2 :(得分:1)

还包括.profile

export VERSIONER_PERL_PREFER_32_BIT=yes; 

除了创建链接外,用DBI::mysql执行程序会产生错误,因此在环境中包含此变量使其正常工作

答案 3 :(得分:1)

我知道这是一个老帖子。但我想最好的解决方案是将库目录添加到DYLD_FALLBACK_LIBRARY_PATH env变量中。 (原因在于:https://stackoverflow.com/a/3172515/119958

mac中没有ldconfig,所以只需添加此env var的路径并重新运行DBD :: mysql的安装过程

Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... FAIL
! Installing DBD::mysql failed. See /Users/donato/.cpanm/build.log for details.

#   Failed test 'use DBD::mysql;'
#   at t/00base.t line 21.
#     Tried to use 'DBD::mysql'.
#     Error:  Can't load '/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/donato/.cpanm/work/1359948144.491/DBD-mysql-4.022/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Library not loaded: libmysqlclient.18.dylib

Donato-Vianas-MacBook-Pro:Invoicer donato$ export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH
Donato-Vianas-MacBook-Pro:Invoicer donato$ cpanm DBD::mysql--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ... OK
Configuring DBD-mysql-4.022 ... OK
Building and testing DBD-mysql-4.022 ... OK
Successfully installed DBD-mysql-4.022
1 distribution installed

答案 4 :(得分:1)

Donato的解决方案适用于安装,但var也必须在运行时出现,否则我会得到相同的错误。以下针对shell和_www user:

在运行时修复此问题
# For command line use, add following line to ~/.bash_profile:
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH

# If Apache needs it, add following line to /etc/apache2/httpd.conf:
# On Lion Server, I put it after <IfDefine MACOSXSERVER>, but shouldn't matter
SetEnv DYLD_FALLBACK_LIBRARY_PATH /usr/local/mysql/lib/:$DYLD_FALLBACK_LIBRARY_PATH

答案 5 :(得分:0)

这有点偏僻,但我强烈建议在机器上设置一个单独的perl - 通过fink / macports,或者从源代码 - 并单独留下Mac的系统perl(和它的库)。

一旦我在自己的Mac上做了这个,我之后安装模块的麻烦很少,而且我不必担心通过打破系统使用的perl而在我的操作系统中意外地漏洞。

如果它是我的Mac,我将从源代码安装一个新的perl(Perl源代码分发足够智能,可以安装自己看到它在Mac上并安全地安装到/ usr / local / bin)并继续从你那里安装DBD :: Mysql(以及你需要的其他模块)。