【问题标题】:How to install mysql gem on Mac os 10.6?如何在 Mac os 10.6 上安装 mysql gem?
【发布时间】:2010-04-26 20:12:46
【问题描述】:

我刚刚在这台 iMac 和 ruby​​gems 上安装了 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

如何安装这个 gem?

【问题讨论】:

  • 现在我无法让它在新的 mac 上工作:S

标签: ruby-on-rails ruby macos gem


【解决方案1】:

我发现了这个并完美解决了:

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

# ruby ./install.rb

安装mysql.rb

【讨论】:

  • 嗯...这个命令行给了我一个错误:“./install.rb:9: 使用 RbConfig 而不是过时和弃用的 Config。”怎么了?
  • 当我发布这个答案时,我使用的是 Ruby 1.8.7,也许我还在使用 Rails 3.2.10,但我现在建议的是:1) 从 dev.mysql.com/downloads 安装 mysql,然后使用rvm 并通过rvm 安装你的mysql gem。旁注:有时您应该使用mysql2 gem 而不是mysql gem。
【解决方案2】:

使用以下对我有用的东西

brew install mysql

【讨论】:

    【解决方案3】:

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

    您可以在这里下载它们:http://developer.apple.com/technologies/xcode.html

    安装后,再试一次。

    【讨论】:

      【解决方案4】:

      我仍然得到这个

      
      $ 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

      【讨论】:

        【解决方案5】:

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

        当 C 库被解压到时,您可能必须传入 --with-mysql-libs 选项以指向目录。希望这能为您指明正确的方向。

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

        【讨论】:

          【解决方案6】:

          从 mysql.com 下载 mysql-dev

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2011-06-25
            • 1970-01-01
            • 2011-02-04
            • 2011-07-29
            • 2012-03-18
            • 2010-12-06
            • 2012-02-14
            • 2010-12-09
            相关资源
            最近更新 更多