1

我一直在试图弄清楚如何让 OS X Lion 与 XAMPP 安装的 MySQL 一起使用 rails 中的 mysql2 gem。

这是我尝试过的:

  • 安装了 XAMPP 开发工具包
  • 安装了带有端口和 brew 的 mysql5-server。这两个我现在都卸载了。因为它没有解决问题。
  • 从 DMG 文件安装 mysql5 社区版。现在卸载了,因为它没有解决问题。
  • 以 tar 格式下载了 mysql5 社区版的 32 位版本。提取文件夹到“/var/mysql”

这是我正在运行以尝试安装它的命令:

gem install mysql2 -- --with-mysql-dir=/var/mysql --with-mysql-include=
/var/mysql/include --with-mysql-lib=/var/mysql/lib --with-mysql-config=
/Applications/XAMPP/xamppfiles/bin/mysql_config

我不知道如何让它发挥作用。我能想到的唯一一件事是我以某种方式没有正确指向目录。我尝试从 with-mysql-include、with-mysql-dir 和 with-mysql-lib 配置选项中删除 /include/、/mysql/ 和 /lib/。没有运气。我已经尝试将它们指向 XAMPP 安装。还是没有运气。

返回的错误是:

ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

/Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-mysql-dir=/var/mysql --with-mysql-include=/var/mysql/include --with-mysql-lib=/var/mysql --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... 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
    --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/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-mysql-config


Gem files will remain installed in /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
4

1 回答 1

5

最好不要打扰 XAMPP 提供的东西,而只需安装一个新的 MySQL 副本,并简化安装 mysql2 的 Gem 命令:

brew install mysql
gem install mysql2

由于这一切,您在通过 Homebrew 安装 MySQL 后安装 gem 时遇到错误:

--with-mysql-dir=/var/mysql --with-mysql-include= \
/var/mysql/include --with-mysql-lib=/var/mysql/lib --with-mysql-config= \
/Applications/XAMPP/xamppfiles/bin/mysql_config

所以删除它可以解决问题。

于 2012-07-01T18:24:56.503 回答