mysql - Mac OS 10.6 服务器无法安装 mysql gem

标签 mysql ruby-on-rails ruby rubygems mysql2

我与下面链接中讨论的问题几乎相同:

Error installing Mysql2 gem- 10.6 Server

我已经遵循了所描述的解决方案,但我得到了这个:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

        /Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** 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=/Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    --with-mysql-config


Gem files will remain installed in /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7 for inspection.
Results logged to /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7/ext/mysql2/gem_make.out

此外,我还尝试指定所有 mysql 路径:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql --
--with-mysql-dir=/usr/local/mysql
--with-mysql-lib=/usr/local/mysql/lib
--with-mysql-include=/usr/local/mysql/include
--with-mysql-config=/usr/local/mysql/bin/mysql_config

还是报错

$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

        /Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** 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=/Users/angelos/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    --with-mysql-config


Gem files will remain installed in /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7 for inspection.
Results logged to /Users/angelos/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7/ext/mysql2/gem_make.out

感谢任何帮助。

最佳答案

您是否在链接的路径中实际安装了 mysql 头文件?有没有安装包含头文件的mysql包?

/usr/local/mysql

我已经用ports安装了mysql,我把它放在/opt里

$ find /opt -name mysql.h
/opt/local/include/mysql5/mysql/mysql.h

你可以试试

$ find /usr/local -name mysql.h

关于mysql - Mac OS 10.6 服务器无法安装 mysql gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7658412/

相关文章:

ruby-on-rails - 在 Ubuntu 12.04 上安装 Ruby on Rails

html - rails 错误: Autoplay is only working sometimes for video_tag

ruby - 如何在 ruby​​ 中快速下载大量网页?并行下载?

mysql - SQL查找一天有最大记录

mysql - Ruby on Rails、MySQL 和 Snow Leopard

mySQL:导入数据库时​​的外键约束

javascript - 如何将 HTML5 麦克风输入捕获到 icecast?

mysql - 设置事件模型的字符串属性(包括撇号)

mysql - Laravel 迁移似乎与迁移方案中编码的内容不同

mysql - 使用 MEDIUMTEXT 和页面的 mySQL 中的数据丢失