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

发布于 2024-10-14 22:54:27 字数 2593 浏览 6 评论 0原文

我正在尝试让 DBD::MySQL 在 Snow Leopard (v10.6.6) 上工作。操作系统附带的默认 Perl 版本是 v5.10.0。因为我读到这是 64 位的,所以我继续下载并安装了 64 位版本的 MySQL (mysql-5.5.8-osx10.6-x86_64)。

安装和设置 MySQL 很顺利,这是我的配置和版本号供参考

我使用 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,我正在努力寻找解决方案。

非常感谢。

I'm attempting to get DBD::MySQL working on Snow Leopard (v10.6.6). The default version of Perl that comes with the OS is v5.10.0. Since I've read that's 64-bit, I went ahead and downloaded and installed a 64-bit version of MySQL (mysql-5.5.8-osx10.6-x86_64).

Installing and setting up MySQL went smoothly, here's my config and version number for reference.

I used CPAN to download DBI and the DBD::MySQL drivers. I then:

  • Installed DBI
  • Setup a Makefile.PL
  • Ran the make command from the command line

The Makefile.PL said it would use the following settings for compiling and testing:

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

Everything seemed to be going fine, until I tried to run 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

It's failing because it can't seem to find the mysql.bundle for DBD. Has anyone come across this problem? Or can point me in the right direction on what to try next? I need DBI/DBD::MySQL for my new job and I'm scrambling to find a solution.

Many thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

撕心裂肺的伤痛 2024-10-21 22:54:27

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

I got around the "Library not loaded: libmysqlclient.16.dylib" problem by placing a symbolic link in /usr/lib/" to /usr/local/mysql-5.5.8-osx10.6-x86_64/lib/libmysqlclient.16.dylib

仙气飘飘 2024-10-21 22:54:27

我解决了相同或类似的问题。不知何故,我可以使用 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

显然,它是 64 位与 32 位问题。

安装 fink dbd-mysql-pm5100 包使它工作,尽管花了很长时间。我还删除了 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 

I worked around the same or a similar issue. Somehow I could build and test DBD::mysql with cpan but when I tried to use it in a script it said things like

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

Apparently, it's a 64-bit vs 32-bit issue.

Installing the fink dbd-mysql-pm5100 package made it work though it took kind of a long time. I also removed the cpan-installed version:

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 
蓝眸 2024-10-21 22:54:27

还包含在 .profile 中

export VERSIONER_PERL_PREFER_32_BIT=yes; 

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

also include in .profile

export VERSIONER_PERL_PREFER_32_BIT=yes; 

Besides creating the link the executions of the program with DBI::mysql generated an error, thus including this variable on the environment make it works

谈场末日恋爱 2024-10-21 22:54:27

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

mac中没有ldconfig,所以只需添加此环境变量的路径并重新运行 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

I know this is an old post. But I suppose the best solution would be to add the library directory to the DYLD_FALLBACK_LIBRARY_PATH env variable. (reason here: https://stackoverflow.com/a/3172515/119958 )

There is no ldconfig in mac, so just add the path to this env var and rerun the install process for 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
难理解 2024-10-21 22:54:27

Donato 的解决方案适用于安装,但 var 也必须在运行时存在,否则我会得到相同的错误。以下内容在运行时针对 shell 和 _www 用户修复了此问题:

# 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

Donato's solution works for install, but the var has to be present at runtime as well or I get the same error. The following fixes this at runtime for shell and _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
白云悠悠 2024-10-21 22:54:27

这有点旁白,但我强烈建议在机器上设置一个单独的 perl - 通过 fink / macports 或从源代码 - 并单独保留 Mac 的系统 perl (及其库)。

一旦我在自己的 Mac 上完成了此操作,此后安装模块就很少遇到问题,而且我不必担心由于破坏系统使用的 perl 而意外地在我的操作系统中炸出一个漏洞。

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

It's somewhat of an aside, but I strongly recommend setting up a separate perl on the machine -- either by fink / macports, or from source -- and leaving the Mac's system perl (and its libraries) alone.

Once I did this on my own Mac, I had very few troubles installing modules thereafter, and I didn't have to worry about accidentally blowing a hole in my OS by breaking the perl that the system uses.

If it were my Mac, I'd install a new perl from source (the Perl source distribution is smart enough to install itself see that it's on a Mac and install itself safely into /usr/local/bin) and the proceed from thee to install DBD::Mysql (and the other modules you require).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文