【问题标题】:Error when trying to install mysql support for rails尝试为 Rails 安装 mysql 支持时出错
【发布时间】:2014-04-11 18:07:03
【问题描述】:

Ruby 版本:1.8.7 (2013-06-27 补丁级别 374) [x86_64-linux] 导轨版本:2.3.5 操作系统:Cloud Linux 64 位

我正在尝试安装mysql gem以获得支持rails,命令如下,

gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config

我收到以下错误,

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-1.8.7-p374/bin/ruby extconf.rb --with-mysql-                                config=/usr/lib64/mysql/mysql_config
extconf.rb:5: command not found: /usr/lib64/mysql/mysql_config --cflags
*** 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=/usr/local/rvm/rubies/ruby-1.8.7-p374/bin/ruby
    --with-mysql-config


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.8.7-p374/gems/mysql-2.9.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.8.7-p374/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

我什至尝试查找 mkmf.log,但找不到。 我正在尝试实现一个已经在 Cent OS 5.9 64bit 中运行的 RoR 项目。此 RoR 设计为在上述版本的 Ruby & Rails 中运行,升级会产生问题。请帮助并指导我。

【问题讨论】:

    标签: mysql ruby-on-rails ruby gem


    【解决方案1】:

    似乎您缺少库的开发部分。 你有安装 libmysqlclient 吗? 配置文件的定位命令的输出是什么?

    locate mysql_config
    

    【讨论】:

    • 不,我还没有安装任何libmysqlclient,如果是我该怎么做,它的版本是什么?如果我运行'locate mysql_config',我会得到以下响应'locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory'
    • 更新所有评论,运行updatedb,以消除错误。现在我得到了很多mysql_client位置不知道用哪一个
    • 最终更新 - 最后我在/usr/bin/mysql_config 找到了 mysql_client 位置。现在一切正常,会持续更新。