2011-04-09 174 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版本,我需要