简体   繁体   English

带有xampp + rails + mysql2 gem的OS X Lion

[英]OS X Lion with xampp + rails + mysql2 gem

I'm stuck trying to figure out how to get OS X Lion with a XAMPP installation's MySQL to work with the mysql2 gem in rails. 我一直试图找出如何通过XAMPP安装的MySQL使OS X Lion与rails中的mysql2 gem一起工作。

Here's what I've tried: 这是我尝试过的:

  • Installed the XAMPP Dev Kit 安装了XAMPP开发套件
  • Installed mysql5-server with both port and brew. 安装了带有端口和brew的mysql5-server。 Both of which I've now uninstalled. 我现在都卸载了这两个。 As it didn't fix the problem. 因为它不能解决问题。
  • Installed mysql5 community edition from DMG file. 从DMG文件安装了mysql5社区版。 Now uninstalled as it didn't fix the problem. 现在已卸载,因为它不能解决问题。
  • Downloaded 32-bit version of mysql5 community edition as a tar. 以tar格式下载了mysql5社区版的32位版本。 Extracted folder to '/var/mysql' 提取文件夹到'/ var / mysql'

Here's the command I'm running to try and get it installed: 这是我正在尝试尝试安装的命令:

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

I'm at a loss how to get this to work. 我很茫然如何使它工作。 The only thing I can think of is that I'm somehow not pointing to the directories correctly. 我唯一能想到的是,我以某种方式未正确指向目录。 I've tried removing /include/, /mysql/ and /lib/ from the with-mysql-include, with-mysql-dir and with-mysql-lib configuration options. 我试过从with-mysql-include,with-mysql-dir和with-mysql-lib配置选项中删除/ include /,/ mysql /和/ lib /。 No luck with that. 没有运气。 I've tried pointing those to the XAMPP installation. 我尝试将其指向XAMPP安装。 No luck still. 仍然没有运气。

The error returned is: 返回的错误是:

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

It'd be better not to bother with the stuff XAMPP provides, and to just install a fresh copy of MySQL, and simplify your Gem command for installing mysql2: 最好不要理会XAMPP提供的东西,而只安装MySQL的新副本,并简化安装mysql2的Gem命令:

brew install mysql
gem install mysql2

You were getting errors with installing the gem after installing MySQL through Homebrew because of all this: 由于所有这些,在通过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

So removing it solves the problem. 因此,删除它可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM