我一直试图弄清楚如何使用XAMPP安装的MySQL获得OS X Lion以使用rails中的mysql2 gem。
这是我尝试过的:
这是我正在运行以尝试安装它的命令:
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
答案 0 :(得分:5)
最好不要打扰XAMPP提供的东西,只需安装一个新的MySQL副本,并简化你的Gem命令来安装mysql2:
brew install mysql
gem install mysql2
由于以下原因,在安装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
因此删除它可以解决问题。