OS X Lion与xampp + rails + mysql2 gem

smb*_*smb 1 ruby mysql xampp mysql2 ruby-on-rails-3

我试图弄清楚如何使用XAMPP安装的MySQL获得OS X Lion以使用rails中的mysql2 gem.

这是我尝试过的:

  • 安装了XAMPP Dev Kit
  • 使用port和brew安装mysql5-server.我现在已经卸载了这两个.因为它没有解决问题.
  • 从DMG文件安装mysql5社区版.现在已卸载,因为它没有解决问题.
  • 下载32位版本的mysql5社区版作为tar.提取的文件夹为'/ 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
Run Code Online (Sandbox Code Playgroud)

我不知道如何让它发挥作用.我唯一能想到的是,我不知何故没有正确指向目录.我试过从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
Run Code Online (Sandbox Code Playgroud)

mrl*_*lee 5

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

brew install mysql
gem install mysql2
Run Code Online (Sandbox Code Playgroud)

通过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
Run Code Online (Sandbox Code Playgroud)

所以删除它解决了这个问题.