用于Ruby On Rails的MySQL Gem

时间:2011-04-15 21:07:03

标签: mysql ruby-on-rails ruby ruby-on-rails-3

我到处搜索,没有解决方案解决我的问题。我使用SQLite而不是MySQL构建了rails应用程序。对于这个特定的项目,我需要MySQL。当我尝试启动服务器时出现错误,因此我尝试为MySQL安装gems并获得另一个错误。有没有人有任何见解?谢谢!

    rails server
    Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile.

    sudo gem install mysql2
    Building native extensions.  This could take a while...
    ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

            /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
    mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


    Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7 for inspection.
    Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/ext/mysql2/gem_make.out

1 个答案:

答案 0 :(得分:3)

我有这个问题。您需要使用本机扩展安装mysql gem。

你可能正在寻找的是:

$ ARCHFLAGS="-arch x86_64" gem install mysql2 --version '~> 0.2.7' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 

全文写下来:http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/