1
votes

Need help getting mysql2 installed. I searched all over and have come to frustration. I'm new in centos and keep hitting certain roadblocks. I've managed to get past most, but i'm looking for help. I get the following running 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

When i run rpm -qa | grep mysql i have the following

[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

most other solutions say to install mysql-devel, but i already have that installed. looking i can see mysql.h in /usr/include/mysql. Most others are also missing the line mysql_config at /usr/bin/mysql_config.

Does anyone have any ides. Thanks!

Edit: Adding a few more details Centos 6.5 Fresh install ( Puppet master from puppet labs repo,then added epel, then theforeman installed, Trying to migrate sqlite to mysql db, but need mysql2 gem installed) Mysql 5.1

2
So after looking at the log mkmf.log, I found a line that started gcc next to mysql.h. I didn't know if i had gcc installed, so i did a yum gcc and tryed another gem install mysql2 and it worked! Hope this helps someone else - blankstar85

2 Answers

0
votes

Ok so i figured it out, I looked at the log mkmf.log located in /usr/lib/ruby/gems/1.8/gems/mysql2-0.3.15/ext/mysql2/mkmf.log and noticed

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

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 */

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

it originally said no, however this is from a successful log, but the thing that i noticed was gcc at the start of the line. I didn't know if i had gcc installed, so I did

yum install gcc

And then my gem install mysql2 and that fixed it.! Hope this helps someone else.

0
votes

I was on gentoo and tried to gem install mysql2, and I had the same error as yours, and I can't find mysql.h anywhere in my system. After googling I ended up removing mysql connector sudo emerge -C dev-db/mysql-connector-c, then reinstall mysql sudo emerge mysql. All headers in /usr/include/mysql are back.

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