在mac os上使用MySQL启动rails服务器时出错

时间:2011-07-20 14:22:53

标签: mysql ruby-on-rails macos

我几天都在修补这个,我仍然得到同样的错误。对于初学者,我已经能够以sqlite作为数据库启动一个新的rails应用程序,但我们正在使用的应用程序使用Mysql。因此,当我转到app目录并输入“rails server”时,它会给我以下内容:

 /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql2-0.2.7/lib/mysql2.rb:8:in `require': dlopen(/Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql2-0.2.7/lib/mysql2.rb:8:in `<top (required)>'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
    from /Users/gojinjedi/Sites/bluey/config/application.rb:7:in `<top (required)>'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

所以(我认为)没有安装MySQL开发头文件,我在网上搜索如何安装它们并尝试了大多数安装命令行还没有成功。我试过的命令示例:

gem install mysql2

sudo env ARCHFLAGS="-arch i386" gem install mysql --   --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib   --with-mysql-include=/usr/local/mysql/include

我在app目录中完成了bundle install,bundle update和bundle命令......我的选项用完了......你能帮助我吗?

我在mac osx 10.7

1 个答案:

答案 0 :(得分:0)

你试过像this这样的东西,我也是一台Mac OS X(狮子),我对mysql gem没有任何问题。或者你可以找到你想要的东西here

<强> [编辑]

或者您可以简单地将ruby-mysql gem用于开发环境