gpt4 book ai didi

mysql - 从 node.js 应用程序连接到 mysql,错误 : "dyld: lazy symbol binding failed: Symbol not found: _mysql_init"

转载 作者:行者123 更新时间:2023-11-29 00:51:55 26 4
gpt4 key购买 nike

我使用 XAMPP 的 OSX 10.6.8 和 MySQL。

当我运行这个 node.js 应用程序 (app.js) 时:

var mysql = require('mysql-libmysqlclient');
var conn = mysql.createConnectionSync();
conn.connectSync('127.0.0.1', 'root', '', 'database_name');

我看到了这个输出:

Airs0urce:nodejs airs0urce$ node app.js 
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Applications/XAMPP/xamppfiles/htdocs/myproject/nodejs/node_modules/mysql-libmysqlclient/build/Release/mysql_bindings.node
Expected in: dynamic lookup

dyld: Symbol not found: _mysql_init
Referenced from: /Applications/XAMPP/xamppfiles/htdocs/myproject/nodejs/node_modules/mysql-libmysqlclient/build/Release/mysql_bindings.node
Expected in: dynamic lookup

Trace/BPT trap

谷歌搜索后已经尝试了几个解决方案。从 XAMPP 目录添加了 mysql 库,以这种方式包含路径:

export DYLD_LIBRARY_PATH=/Applications/XAMPP/xamppfiles/lib/mysql:$DYLD_LIBRARY_PATH

尝试使用 MacPorts 安装 mysql5-devel,但没有成功,构建失败:

Airs0urce:~ airs0urce$ sudo port install mysql5-devel
---> Computing dependencies for mysql5-devel
---> Building mysql5-devel
Error: Target org.macports.build returned: shell command failed (see log for details)
Log for mysql5-devel is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_mysql5-devel/mysql5-devel/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

想看日志文件有:http://dl.dropbox.com/u/1875424/main.log

最佳答案

这是因为 Mac OS X Lion (10.7) 上的配置问题:lib/libmysqlclient.18.dylib(mysql 5.5 及更高版本)。

第一步:

确保在 ~/.profile 中设置路径

export ARCHFLAGS=-arch x86_64
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

第 2 步:

我正在使用 rvm,所以我使用了以下命令:

rvmsudo ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-opt-lib=/usr/local/mysql/lib 

解决了 Mac lion 和 mysql x86_64 上的 rails 应用问题。

关于mysql - 从 node.js 应用程序连接到 mysql,错误 : "dyld: lazy symbol binding failed: Symbol not found: _mysql_init",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8156024/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com