如何在Mac OS 10.6.6上安装gem MySQL

时间:2011-05-30 17:15:05

标签: mysql ruby-on-rails macos

Ruby已安装在Mac上。所以我刚刚安装了rails。

ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

rails 2.3.11

gem 1.3.5

当我尝试:gem install mysql我收到此错误:

89-235-235-64:~ vitali$ gem install mysql
WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
      /usr/bin aren't both writable.
WARNING:  You don't have /Users/vitali/.gem/ruby/1.8/bin in your PATH,
      gem executables will not run.
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    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 /Users/vitali/.gem/ruby/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Users/vitali/.gem/ruby/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
89-235-235-64:~ vitali$ 

不明白该怎么做。 gem安装mysql安装没有MySQl本身或者我应该下载并安装MySQL作为prorgamm?如果是,从什么资源,什么版本,如何安装?请帮助我,我的新手在mac上。非常感谢!

1 个答案:

答案 0 :(得分:1)

你几乎肯定需要安装MySQL以安装MySQL gem(更好的是mysql2 gem,Rails也可以使用 - 只需在你的database.yml文件中使用mysql2而不是mysql)。 / p>

我发现在Mac上格式化MySQL的最佳方法(无可否认,很少)是使用Homebrew。所以,如果你没有安装Homebrew,我会从那开始......一旦完成,它应该是运行sudo brew install mysql,并在安装完成后运行它提供的指令。