本文介绍了Ruby On Rails的MySQL Gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处搜索,没有一个解决方案可以解决我的问题.我已经使用SQLite而不是MySQL构建了Rails应用程序.对于这个特定的项目,我需要MySQL.当我尝试引导服务器时,出现错误,因此尝试为MySQL安装gems并收到另一个错误.有人有见识吗?谢谢!

I have searched everywhere and no ones solutions solve my problem. I have built rails apps using SQLite but not MySQL. For this particular project, I need MySQL. When I attempt to boot the server I get an error, so I attempt to install the gems for MySQL and get another error. Does anyone have any insight? Thank you!

    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

推荐答案

我遇到了这个问题.您需要安装具有本机扩展的mysql gem.

I had this problem. You need to install the mysql gem with native extensions.

您可能正在寻找的行是这样的:

The line you're probably looking for is this:

$ 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/

Full write up on getting it going here: http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/

这篇关于Ruby On Rails的MySQL Gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:20