从node.js应用程序连接到mysql,错误:“dyld:惰性符号绑定失败:未找到符号:_mysql_init”
我使用 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
I use OSX 10.6.8 and MySQL from XAMPP.
When I run this node.js app (app.js):
var mysql = require('mysql-libmysqlclient');
var conn = mysql.createConnectionSync();
conn.connectSync('127.0.0.1', 'root', '', 'database_name');
I see this output:
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
Already tried couple solutions after googling.
Added mysql libs from XAMPP directory to include path this way:
export DYLD_LIBRARY_PATH=/Applications/XAMPP/xamppfiles/lib/mysql:$DYLD_LIBRARY_PATH
tried to install mysql5-devel
using MacPorts, but no luck, building failed:
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>
There is log file if you want to see: http://dl.dropbox.com/u/1875424/main.log
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为 Mac OS X Lion (10.7) 上的配置问题:
lib/libmysqlclient.18.dylib
(mysql 5.5 及更高版本)。第 1 步:
确保在
~/.profile
中设置路径第 2 步:
我使用的是 rvm,因此,我使用了以下命令:
它解决了 Mac lion 和 mysql x86_64 上的 Rails 应用程序的问题。
This is because of a config issue on Mac OS X Lion (10.7):
lib/libmysqlclient.18.dylib
(mysql 5.5 and above).Step 1:
Make sure you set the path in
~/.profile
Step 2:
I am using rvm so, I used the following command:
which has solved the issues with rails application on Mac lion and mysql x86_64.
我为此花了很多时间,包括设置 DVLD 库路径并将库复制到 /usr/lib 中。
sudo cp /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib
哎呀,任何让它工作的东西。最后我尝试清除 64 位和 32 位的默认值,结果成功了!
defaults delete com.apple.versioner.perl
不确定我的 perl 是 64 位还是 32 位,但我的数据库是 64 位,仅使用默认的 default 似乎效果更好;-)
I futzed around with this for a ton of time including setting the DVLD library path and copying the library into /usr/lib.
sudo cp /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib
Heck, anything to get it working. Finally I tried clearing the default for 64 vs 32 bit and it worked!
defaults delete com.apple.versioner.perl
Not sure if my perl is 64 or 32 bit, but my db is 64 bit and just using the default default seems to work better ;-)