mysql2 gem installation fails

杀马特。学长 韩版系。学妹 提交于 2019-12-08 01:10:59

问题


My stack is as follows:

  • 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 mysql Ver 14.14 Distrib 5.5.27, for Linux (x86_64) using readline 5.1

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

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

    $> uname -a Linux 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 -v nginx version: nginx/1.2.2

    $> rails -v Rails 3.2.6

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

When I do

$> find / -name mysql.h  

I get nothing

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

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

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


回答1:


I got this working:

 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



回答2:


have you installed mysql ? if not do so also you need to install the mysql dev files for native compilation of gem

sudo yum install mysql-devel

check this already explained Errors Installing mysql2 gem via the Bundler




回答3:


if get the error like this

$ sudo yum install mysql-devel

Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
10gen                                                                                                                                                      | 2.5 kB     00:00
base                                                                                                                                                       | 3.7 kB     00:00
centosplus                                                                                                                                                 | 3.4 kB     00:00
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Wed Feb 12 07:03:25 2014
  Downloaded: Sat Jan  4 21:29:15 2014
contrib                                                                                                                                                    | 2.9 kB     00:00
epel                                                                                                                                                       | 4.2 kB     00:00
epel/primary_db                                                                                                                                            | 5.9 MB     00:00
extras                                                                                                                                                     | 3.4 kB     00:00
newrelic                                                                                                                                                   |  951 B     00:00
rpmforge                                                                                                                                                   | 1.9 kB     00:00
rpmforge-extras                                                                                                                                            | 1.9 kB     00:00
ucloud                                                                                                                                                     | 1.3 kB     00:00
updates                                                                                                                                                    | 3.4 kB     00:00
updates/primary_db                                                                                                                                         | 2.0 MB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-devel.x86_64 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-devel-5.1.73-3.el6_5.x86_64
--> Finished Dependency Resolution
Error: Package: mysql-devel-5.1.73-3.el6_5.x86_64 (updates)
           Requires: mysql = 5.1.73-3.el6_5
           Installed: mysql-5.5.34-1.el6.remi.x86_64 (@remi)
               mysql = 5.5.34-1.el6.remi
           Available: mysql-5.1.71-1.el6.x86_64 (base)
               mysql = 5.1.71-1.el6
           Available: mysql-5.1.73-3.el6_5.x86_64 (updates)
               mysql = 5.1.73-3.el6_5
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

try this

sudo yum --enablerepo=remi -y install mysql-devel



回答4:


To get the header files for any piece of software you need to install the -dev or -devel variant. Since you're using a non-standard RPM, you might want to see if the same source has that version.

Once those are installed you shouldn't have any issues.



来源:https://stackoverflow.com/questions/12119567/mysql2-gem-installation-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!