2011-12-08 199 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上有很多 –