当前位置: 首页 > 工具软件 > Gem Framework > 使用案例 >

rails mysql gem_用於Ruby On Rails的MySQL Gem

厉成仁
2023-12-01

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!

我到處搜索,沒有解決方案解決我的問題。我使用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 个解决方案

#1

3

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

我有這個問題。您需要使用本機擴展安裝mysql gem。

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/

 类似资料: