首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在mysql2 1.9.3下安装Ruby?在2.0.0下工作

问如何在mysql2 1.9.3下安装Ruby?在2.0.0下工作
EN

Stack Overflow用户
提问于 2013-06-26 00:55:52
回答 5查看 5.8K关注 0票数 6

在我的机器上安装mysql2 gem时遇到了问题。

我有OSX10.8和最新的Xcode,mySql是通过Homebrew安装的。使用最新的RVM安装的所有红宝石。

我可以在Ruby2.0.0-P195下安装mysql2

代码语言:javascript
复制
[~]$ rvm use 2.0.0                                                              [ruby-1.9.3-p429]
Using /Users/aselder/.rvm/gems/ruby-2.0.0-p195
[~]$ gem in mysql2                                                              [ruby-2.0.0-p195]
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.11
1 gem installed

在Ruby 1.9.3和1.8.7下,它找不到mysql.h文件

代码语言:javascript
复制
    [~]$ rvm use 1.9.3                                                              [ruby-1.9.3-p429]
    Using /Users/aselder/.rvm/gems/ruby-1.9.3-p429
    [~]$ gem in mysql2                                                              [ruby-1.9.3-p429]
    Fetching: mysql2-0.3.11.gem (100%)
    Building native extensions.  This could take a while...
    ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

            /Users/aselder/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
    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/aselder/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
        --with-mysql-config
        --without-mysql-config


    Gem files will remain installed in /Users/aselder/.rvm/gems/ruby-1.9.3-p429/gems/mysql2-0.3.11 for inspection.
    Results logged to /Users/aselder/.rvm/gems/ruby-1.9.3-p429/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

我还尝试了所有不同的命令行选项,让gem找到mysql安装:

例如gem install mysql2 -- gem

EN

回答 5

Stack Overflow用户

发布于 2013-08-30 02:08:02

我找到了这个答案,它解决了我的问题:Error installing mysql2: Failed to build gem native extension

引用:

在Ubuntu/Debian和其他使用aptitude的发行版上:

代码语言:javascript
复制
sudo apt-get install libmysql-ruby libmysqlclient-dev

在Red Hat/CentOS和其他使用yum的发行版上:

代码语言:javascript
复制
sudo yum install mysql-devel

在装有Homebrew的Mac OS X上:

代码语言:javascript
复制
brew install mysql

我在debian上,在运行上面的命令后,我运行:

代码语言:javascript
复制
gem install mysql2

它在np中起作用。

票数 4
EN

Stack Overflow用户

发布于 2013-10-19 00:13:52

我解决了在mysql服务器启动时安装gem的问题!

代码语言:javascript
复制
brew install mysql

mysql.server start

bundle install

在ruby-1.9.3-p125下。

希望这能有所帮助

票数 1
EN

Stack Overflow用户

发布于 2013-06-26 02:29:11

尝试使用Homebrew安装mysql,并使用Bundler安装mysql2 gem。

代码语言:javascript
复制
brew update
brew install mysql

将以下内容添加到您的Gemfile

代码语言:javascript
复制
gem "mysql2"

运行:

代码语言:javascript
复制
bundle install
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17303195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档