MySQL 捆绑安装

标签 mysql ruby-on-rails

我浏览了 stackoverflow 上的多个问题,它们都给出了不同的解决方案。我git克隆了一个rails项目,运行bundle install,并使用1.9.3 ruby​​在rvm中创建了一个新的gemset,并且认为rails 3.2.13也将使用bundle install命令安装。过去我通过使用本指南解决了这个问题,http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html 。我在 user/local 中找不到 mysql 文件夹,指南说我需要编辑一个文件并删除一些行来解决 mysql.h 丢失的问题。该文件不再存在?我没找到?也许我缺少依赖项,但我找到了这些依赖项的 linux 安装方式?也许我需要安装 mysql5.5 而不是最新版本,但不确定如何指定?其中哪一个可以为我解决这个问题?

Installing mysql2 (0.3.11) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

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


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

An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

最佳答案

您需要先设置 mysql 开发头文件(因此,.h 文件扩展名),然后bundle/gem 才能构建您的 native mysql 扩展。您使用的是哪个操作系统?所以我可以扩展我的答案......

例如在 debian 上,它将是:apt-get install libmysqlclient-dev(在其他系统上,它可能被命名为不同,例如 mysql-devel)。如果您使用的是 OSX,那么 bundle install problem: mysql.h is missing 上有非常丰富的答案。这可能对你有帮助。对于 Windows,这可能会有所帮助:Missing mysql.h and trying to find mysql-devel .

关于MySQL 捆绑安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17601926/

相关文章:

ruby-on-rails - 在 Rails 3 上使用计算进行分组查询

ruby-on-rails - Rails API ActionController::RoutingError:没有路由匹配 [POST] "/goals"

Mysql游标循环只运行一次

mysql - 类似运算符的SQL查询

php - 基于角色的登录

ruby-on-rails - 在表单验证错误时重定向到路由别名

ruby-on-rails - 按模型与特定属性的关联计数排序

mysql - 仅当存在多个不等于 0 的值时,SQL 查询平均值才存在?

mysql - Facebook Graph API 2 - 存储在数据库中时的用户 ID 类型

ruby-on-rails - 带 Stripe 结账的 Rails : How can i seed my db with sample charges and use stripe checkout to generate tokens for each charge?