本文介绍了mysql2 gem安装失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的堆栈如下:

  • CentOS 6.3
  • Installed MySQL 5.5 (followed steps at http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/ because yum still has MySQL 5.1 and if I try to yum install any mysql related package, it will of course break as yum will expect 5.1)

$> mysql --version适用于Linux(x86_64)的mysql Ver 14.14 Distrib 5.5.27,使用readline 5.1

$> mysql --versionmysql Ver 14.14 Distrib 5.5.27, for Linux (x86_64) using readline 5.1

$> ruby​​ --versionruby 1.9.3p194(2012-04-20修订版35410)[x86_64-linux]

$> ruby --versionruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

$> rvm --versionrvm 1.14.6(稳定),作者:Wayne E. Seguin,Michal Papis [https://rvm.io/]

$> rvm --versionrvm 1.14.6 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

$> uname -aLinux localhost.mkf 2.6.32-279.5.1.el6.x86_64#1 SMP Tue Aug 14 23:54:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

$> uname -aLinux localhost.mkf 2.6.32-279.5.1.el6.x86_64 #1 SMP Tue Aug 14 23:54:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

$> nginx -vnginx版本:nginx/1.2.2

$> nginx -vnginx version: nginx/1.2.2

$> rails -vRails 3.2.6

$> rails -vRails 3.2.6

当我尝试安装mysql2 gem时,出现以下错误:

When I try to install mysql2 gem, I get following error:

$> gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p194/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=/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-mysql-config
--without-mysql-config


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11       for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-    0.3.11/ext/mysql2/gem_make.out

当我这样做

$> find / -name mysql.h

我什么也没得到

Mysql运行正常,我已经在其中创建了数据库和表,并且sql在运行时没有任何问题.

Mysql is running properly and I have already created db and tables in it and sql are running without any issue.

是否可以在堆栈中安装mysql2 gem?如果是这样,那么我有什么想法吗?

Is it possible to have mysql2 gem installed in my stack? If so then any idea what I am missing?

更新:我尝试yum install mysql-devel会引发错误,因为我使用Remi存储库安装了mysql5.5.虽然百胜期待mySql 5.1

UPDATE : I tried yum install mysql-devel it throws error because Ihave mysql5.5 installed, using Remi repository. While Yum expectsmySql 5.1

推荐答案

我正在执行此工作:

 wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.27-1.el6.x86_64.rpm

 rpm -Uvh MySQL-devel-5.5.27-1.el6.x86_64.rpm

 gem install mysql

 gem install mysql2

这篇关于mysql2 gem安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 22:39