宝石mysql2安装

时间:2014-04-28 15:27:53

标签: mysql gem centos

需要帮助才能安装mysql2。我搜遍了所有人并且感到沮丧。我是新人,不断遇到某些障碍。我设法过了最多,但我正在寻求帮助。我得到以下运行 gem install mysql2

[root bin]# gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for rb_hash_dup()... no
checking for rb_intern3()... no
-----
Using mysql_config at /usr/bin/mysql_config
-----
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
    --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/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysql-config
    --without-mysql-config


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql2-0.3.15 for       inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql2-0.3.15/ext/mysql2/gem_make.out

当我运行rpm -qa |时grep mysql我有以下

[root bin]# rpm -qa | grep mysql
mysql-server-5.1.73-3.el6_5.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
mysql-devel-5.1.73-3.el6_5.x86_64
mysql-5.1.73-3.el6_5.x86_64

大多数其他解决方案都说安装mysql-devel,但我已经安装了。我可以在/ usr / include / mysql中看到mysql.h。大多数其他人也错过了/ usr / bin / mysql_config中的mysql_config行。

有没有人有任何想法。谢谢!

编辑:添加更多细节 Centos 6.5全新安装(木偶大师从木偶实验室回购,然后添加了epel,然后安装了,尝试将sqlite迁移到mysql db,但需要安装mysql2 gem) Mysql 5.1

2 个答案:

答案 0 :(得分:0)

好的,所以我想通了,我查看了位于/usr/lib/ruby/gems/1.8/gems/mysql2-0.3.15/ext/mysql2/mkmf.log中的日志mkmf.log并注意到了

--------------------

have_header: checking for mysql.h... -------------------- yes

"gcc -E -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -I/usr/include/mysql    -O2 -g -pipe         -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64   -mtune=generic -fno-strict-aliasing  -fPIC    conftest.c$
checked program was:
/* begin */
1: #include <mysql.h>
/* end */

--------------------

它最初说没有,但这是来自一个成功的日志,但我注意到的是在行的开头是gcc。我不知道我是否安装了gcc,所以我做了

yum install gcc

然后我的gem安装了mysql2并修复了它。希望这有助于其他人。

答案 1 :(得分:0)

我在gentoo上尝试gem install mysql2时遇到了与您相同的错误,并且在系统中的任何地方都找不到mysql.h。谷歌搜索后,我最终删除了mysql连接器sudo emerge -C dev-db/mysql-connector-c,然后重新安装mysql sudo emerge mysql/usr/include/mysql中的所有标题都回来了。

Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... no