在我的OSX 10.7.3
上安装了Rails 3.2.3和MySQL 5.6我创建了一个名为“simple_cms”的新项目,然后在终端中尝试使用“rails server”启动webrick并且什么也没得到。
Hideyoshis-MacBook-Pro:simple_CMS gregpfeffer $ rails s
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle:dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2。 bundle,9):未加载库:libmysqlclient.18.dylib(LoadError)
参考自:/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
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in
require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in
require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in
require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in require'
from /Users/gregpfeffer/Sites/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53:in
require'
来自/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50:in tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50
from script/rails:6:in
require'
来自script / rails:6
Hideyoshis-MacBook-Pro:simple_CMS gregpfeffer $ sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.4/lib /mysql2/mysql2.bundle
install_name_tool:无法打开文件:/Library/Ruby/Gems/1.8/gems/mysql2-0.2.4/lib/mysql2/mysql2.bundle(没有这样的文件或目录)
答案 0 :(得分:2)
尝试添加:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH
到你的.bash_profile
这假设您接受了mysql的默认安装位置