2011-04-09 172 views
3

所以我知道這個問題已經被問過了,而且我查看了所有以前的答案,但仍然找不到解決方案。希望你們都能幫忙。MySQL Ruby Gem安裝問題

設置:我正在運行Mac OS X 10.6服務器。我已經使用內置的MySQL安裝在網絡應用程序,它很好。現在我正在嘗試運行需要MySQL的RoR應用程序。

所以,每當我進入

gem install mysql 

它吐出回以下錯誤:

Building native extensions. This could take a while... 
ERROR: Error installing mysql: 
    ERROR: Failed to build gem native extension. 

/Users/admin/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb --with-mysql-config=/var/mysql 
*** 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 
    --without-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/admin/.rvm/rubies/ruby-1.9.2-p180/bin/ruby 
    --with-mysql-config 
extconf.rb:35:in ``': Permission denied - /var/mysql --cflags (Errno::EACCES) 
    from extconf.rb:35:in `<main>' 


Gem files will remain installed in /Users/admin/.rvm/gems/[email protected]/gems/mysql-2.8.1 for inspection. 
Results logged to /Users/admin/.rvm/gems/[email protected]/gems/mysql- 2.8.1/ext/mysql_api/gem_make.out 

所以,通過我的研究,我想具體說明了MySQL的安裝位置。

gem install mysql -- --with-mysql-config=/var/mysql 

不幸的是,結果也一樣。

任何想從哪裏去這裏?

謝謝!

凱文

+0

有沒有使用mysql2理由嗎? – 2011-04-09 19:30:52

+0

http:// stackoverflow。com/questions/2167598/mysql-install-error-failed-to-build-gem-native-extension – fl00r 2011-04-09 20:06:09

+0

http://stackoverflow.com/questions/354194/mysql-installation-troubles – fl00r 2011-04-09 20:06:29

回答

0

你milage可能會有所不同,但這裏是什麼似乎爲我們工作。首先,確保你有沒有第一(蘋果)正確的庫:

http://www.opensource.apple.com/other/MySQL-53.binaries.tar.gz

安裝通過這些:

sudo tar -xvf ~/Downloads/MySQL-53.binaries.tar -C/

然後,我們10.6服務器,mysql_config的位置是不同:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config 
+0

我安裝了mysql使用自制軟件,我得到「權限被拒絕」的錯誤。錯誤:執行gem時(Errno :: EACCES) 權限被拒絕 - /Users/pratikkhadloya/.rvm/gems/ruby​​-1.8.7-p352/gems/mysql-2.8.1/COPYING' – 2011-08-08 16:52:51

+0

看起來,我以前的mysql的gem安裝是使用sudo完成的,所以我卸載了它,然後重新安裝並運行。 – 2011-08-08 17:29:31

0
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"' 

使用上面的工作與Windows上的紅寶石Ruby 2.0。我將庫改爲lib而不是lib\opt,因爲lib\opt不存在於MySQL Server 5.5中。

我從這個問題的解決方案在提交拿起上面的命令: http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

1

在Mac OSX獅子10.7命令幫我安裝mysql2寶石:

sudo gem install mysql2 -- --with-mysql-lib=/usr/local/Cellar/mysql55/5.5.30/lib --with-mysql-include=/usr/local/Cellar/mysql55/5.5.30/include/ 

在此之前我沒有安裝mysql55通過如上所述的brew來完成。

0

我有這個須藤寶石安裝成功mysql -v '2.8.1' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 但指定的MySQL版本,我需要