2012-07-01 50 views
1

我一直在試圖弄清楚如何讓OS X Lion與XAMPP安裝的MySQL一起使用在rails2中的mysql2 gem。OS X Lion with xampp + rails + mysql2 gem

這是我已經試過:

  • 安裝了XAMPP開發套件
  • 安裝MYSQL5服務器與兩個端口和啤酒。這兩個我現在卸載。因爲它沒有解決問題。從DMG文件
  • 安裝MYSQL5社區版。現在卸載,因爲它沒有解決問題。
  • 下載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 
+0

嗯。那麼做到了!我不知道爲什麼它沒有這樣做......謝謝! – SB2017

+0

將評論移到答案中,因爲它解決了問題。 – mrlee

回答

5

這將會是最好不要用那東西XAMPP提供打擾,並只安裝MySQL的全新副本,並簡化您的寶石命令安裝mysql2:

brew install mysql 
gem install mysql2 

你通過,因爲這一切自制安裝MySQL安裝後的寶石均得到錯誤:

--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 

因此,刪除它可以解決問題。

+0

謝謝!你確定。幫助解決這個問題... – SB2017

+0

我已經從我的系統中永遠刪除了XAMPP。我有所有這些不同的MySQL庫在我的系統周圍浮動。我儘可能地將它們清理乾淨,並隨釀造版本一起使用。似乎現在工作正常。那是5個小時的時間...... – Dex