如何在Mac OS 10.6上安装mysql gem?

时间:2010-04-26 20:12:47

标签: ruby-on-rails ruby macos gem

我刚刚在这个iMac和rubygems上安装了MAMP,但是当我运行时:

sudo gem install mysql - -with-mysql-config = / usr / local / mysql / bin / mysql_config

给了我


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 /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out ERROR: could not find gem — locally or in a repository ERROR: could not find gem –with-mysql-config=/usr/local/mysql/bin/mysql_config locally or in a repository

我该如何安装这个宝石?

6 个答案:

答案 0 :(得分:5)

我找到了这个并且完美地完成了:

你可以去http://www.tmtm.org/en/ruby/mysql/下载tar 文件,并运行以下命令

# ruby ./install.rb

安装mysql.rb

答案 1 :(得分:5)

使用以下它与我合作

brew install mysql

答案 2 :(得分:3)

您是否在Mac OS X上安装了Xcode开发人员工具?如果没有,我会从那里开始。

您可以在此处下载:http://developer.apple.com/technologies/xcode.html

安装完毕后,请重试。

答案 3 :(得分:2)

我还在接受这个


$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config 
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 --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config checking for mysql_ssl_set()... no checking for rb_str_set_len()... no checking for rb_thread_start_timer()... no checking for mysql.h... no checking for mysql/mysql.h... no * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-mysql-config

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

答案 4 :(得分:1)

你需要mysql开发库来编译它。如果你在linux上,你可以使用“yum install mysql-devel”。不确定如何在Mac上安装它们,但尝试从这里下载连接器库: MySql Connector Downloads

您可能必须传入--with-mysql-libs选项以指向解压缩C库时的目录。希望这能指出你正确的方向。

或者您可以将库放在默认目录中: 的/ usr / lib64下/ MySQL的

答案 5 :(得分:-1)

从mysql.com下载mysql-dev