2011-12-08 162 views
3

可能重复:
Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem耙分贝:迁移(MySQL的)

为什么我得到这个错误?什么意思?

我已经安装了mysql2宝石, “sudo的创业板安装mysql2”

的Gemfile:

gem 'mysql2' 

〜:耙分贝:迁移--trace

rake aborted! 
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib 
    Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle 
    Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle 
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle 
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each' 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `require' 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each' 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require' 
/Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:122:in `require' 
/Users/leonardo/dev/myproject/config/application.rb:7 
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require' 
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require' 
/Users/leonardo/dev/myproject/Rakefile:5 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/bin/rake:33 
/usr/bin/rake:19:in `load' 
/usr/bin/rake:19 
+2

已解决:http://stackoverflow.com/a/6100648/1028100 谢谢你!现在你可以关闭这个问题 – sparkle

回答

3

把这段代码在.profile和.bash_profile文件中。

alias ll="ls -lahG" 
alias whereami="pwd" 

export PATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/my$ 
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH" 

注意:如果你不知道该怎么做,在终端每次打开它的时候......

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

这是我的.bash_profile文件看起来像这样类型编辑你的bash,在根($)终端菜单中,输入ls -la,然后输入nano .bash_profile和/或nano .profile进入bash的文本编辑器(我只是保持它们都一样,它可能是多余的,不知道)。

一旦完成编辑,点击ctrl-X,然后点击'返回'返回到主菜单,可以这么说。

+0

或者只是改变你的config/database.yml文件来使用sqlite3。如果你不需要使用mysql,你不应该使用mysql。 sqlite3是非常好的,你可以随时跳到MySQL,只要你喜欢它。对于sqlite3的database.yml文件,google一定会在github.com上有很多 –