2009-12-06 97 views
9

我想我的雪Leopord系统的MacBook Pro 13" 上安装do_mysql,但我不断收到此错误:无法安装do_mysql gem?

n216-160:~ myself$ sudo gem1.9 install do_mysql 
Password: 
Building native extensions. This could take a while... 
ERROR: Error installing do_mysql: 
    ERROR: Failed to build gem native extension. 

/opt/local/bin/ruby1.9 extconf.rb 
checking for mysql_query() in -lmysqlclient... no 
*** 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=/opt/local/bin/ruby1.9 
    --with-mysql-config 
    --without-mysql-config 
    --with-mysql-dir 
    --without-mysql-dir 
    --with-mysql-include 
    --without-mysql-include=${mysql-dir}/include 
    --with-mysql-lib 
    --without-mysql-lib=${mysql-dir}/lib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 


Gem files will remain installed in /opt/local/lib/ruby1.9/gems/1.9.1/gems/do_mysql-0.10.0 for inspection. 
Results logged to /opt/local/lib/ruby1.9/gems/1.9.1/gems/do_mysql-0.10.0/ext/do_mysql_ext/gem_make.out 
n216-160:~ myself$ 

我不知道为什么我还重新安装我的MySQL的verison与MySQL。 5.4.3测试版,64位的其他建议,但没有骰子。没有人有任何的想法有什么不好?

回答

2

试试这个

sudo env ARCHFLAGS="-arch x86_64"
gem install do_mysql --with-mysql-dir=/usr/local/mysql/ --ruby=/opt/local/bin/ruby1.9

你必须指定你的MySQL插件的位置tallation,以及红宝石安装的位置,因为你使用的是ruby1.9,我假设你的机器上可能有1.8的运行。

24

您缺少libmysqlclient-dev软件包。在德布系统,你可以使用

sudo apt-get install libmysqlclient-dev 

不知道有关Mac安装这个(也许“sudo的港口安装的libmysqlclient-dev的”?)

+1

RPM相当于:'须藤荫安装mysql-devel' – TheLQ 2011-01-21 21:25:31

+0

这个工作对我来说,同样的问题OP。 – 2011-07-24 04:01:39

+1

或'brew install mysql' http://stackoverflow.com/questions/3608287/installing-mysql2-gem-for-rails-3 – 2012-06-01 18:28:36

9

我有同样的问题,并将上述溶液没有,直到我的工作固定我的$ PATH: PATH = “在/ usr/local/bin目录:在/ usr/local/sbin中:$ PATH” #如果不是已经存在 PATH = “$ PATH:在/ usr /本地/ MySQL的/ bin中” 导出路径= $ PATH

2

您需要安装Mysql并将Mysql二进制文件的路径添加到您的配置文件。

1)下载并安装MySQL二进制文件(确保选择正确的CPU架构)。

2)编辑文件~/.profile并将:/usr/local/mysql/bin添加到您的路径。

3)在一个新的终端窗口做sudo gem install do_mysql

希望帮助!

干杯,

马库斯

6
sudo env ARCHFLAGS="-arch x86_64" gem install do_mysql -- --with-mysql-dir=/usr/local/mysql/ 
+2

优秀的这个工作! – 2012-01-23 03:24:44

+0

工作感谢! – 2013-10-27 20:47:27

+0

这是有史以来最有用的一件事。 – 2013-12-05 18:53:25