3

所以我知道这个问题之前已经被问过,并且我已经查看了之前的所有答案,但仍然找不到解决方案。希望大家能帮忙。

设置:我正在运行 Mac OS X 10.6 服务器。我在 Web 应用程序上使用了内置的 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/ruby-1.9.2-p180@rails3/gems/mysql-2.8.1 for inspection.
Results logged to /Users/admin/.rvm/gems/ruby-1.9.2-p180@rails3/gems/mysql-    2.8.1/ext/mysql_api/gem_make.out

因此,通过我的研究,我试图具体说明 MySQL 安装的位置。

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

不幸的是,结果相同。

关于从这里去哪里的任何想法?

谢谢!

凯文

4

5 回答 5

5

凯文,

本文可能会帮助您解决您的问题:

http://rapd.wordpress.com/2007/05/17/battle-against-ror-gem-install-mysql/

于 2011-04-09T21:06:43.240 回答
1

在 Mac OSX Lion 10.7 上,这个命令帮助我安装了 mysql2 gem:

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/

在此之前,我确实通过 brew 安装了 mysql55,如上所述。

于 2014-01-14T21:27:12.730 回答
0

您的里程可能会有所不同,但这似乎对我们有用。首先,确保您首先在那里拥有正确的库来自 Apple):

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

通过以下方式安装它们:

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

然后,对于我们的 10.6 Server,mysql_config 的位置是不同的:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
于 2011-05-13T16:07:37.280 回答
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​​ Ruby 2.0 一起使用。我将库更改为 justlib而不是lib\opt因为lib\optMySQL Server 5.5 中不存在。

我从解决此问题的解决方案中选择了上述命令: http ://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

于 2013-08-18T18:29:18.010 回答
0

我在这个 sudo gem install 上取得了成功,mysql -v '2.8.1' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 但指定了我需要的 mysql 版本

于 2015-09-24T15:21:57.987 回答