OSX v10.6.6 上 DBD::MySQL 安装错误
我正在尝试让 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我通过在 /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
我解决了相同或类似的问题。不知何故,我可以使用
cpan
构建和测试 DBD::mysql,但是当我尝试在脚本中使用它时,它会说“显然,它是 64 位与 32 位问题。
安装 fink dbd-mysql-pm5100 包使它工作,尽管花了很长时间。我还删除了 cpan 安装的版本:
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 likeApparently, 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:
还包含在 .profile 中
除了创建链接之外,使用
DBI::mysql
执行程序会生成错误,因此在环境中包含此变量使其可以工作also include in .profile
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我知道这是一个旧帖子。但我认为最好的解决方案是将库目录添加到 DYLD_FALLBACK_LIBRARY_PATH 环境变量中。 (原因在这里:https://stackoverflow.com/a/3172515/119958)
mac中没有ldconfig,所以只需添加此环境变量的路径并重新运行 DBD::mysql 的安装过程
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 的解决方案适用于安装,但 var 也必须在运行时存在,否则我会得到相同的错误。以下内容在运行时针对 shell 和 _www 用户修复了此问题:
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:
这有点旁白,但我强烈建议在机器上设置一个单独的 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).