1

I have a problem installing mysql ruby gem on 64bit CentOS machine.

[jacekb@vitaidealn ~]$ uname -a
Linux vitaidealn.local 2.6.18-92.el5 #1 SMP Tue Jun 10 18:51:06 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

Mysql and mysql-devel packages are installed. Mysql_config provides following paths:

Usage: /usr/lib64/mysql/mysql_config [OPTIONS]
Options:
    --cflags         [-I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv]
    --include        [-I/usr/include/mysql]
    --libs           [-L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto]
    --libs_r         [-L/usr/lib64/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib64 -lssl -lcrypto]
    --socket         [/var/lib/mysql/mysql.sock]
    --port           [3306]
    --version        [5.0.45]
    --libmysqld-libs [-L/usr/lib64/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt -L/usr/lib64 -lssl -lcrypto]

Trying to install:

[jacekb@vitaidealn ~]$ gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql
...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby extconf.rb --with-mysql-include=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql
    checking for mysql_query() in -lmysqlclient... no
    checking for main() in -lm... no
    checking for mysql_query() in -lmysqlclient... no
    checking for main() in -lz... no
    checking for mysql_query() in -lmysqlclient... no
    checking for main() in -lsocket... no
    checking for mysql_query() in -lmysqlclient... no
    checking for main() in -lnsl... no
    checking for mysql_query() in -lmysqlclient... no
    *** 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.

I would appreciate any help. Thanks for reading :).

5 Answers5

5

I think you need the devel package for the mysql-client. Try to install it with:

yum install mysql-devel
hdanniel
  • 4,293
  • 23
  • 25
  • on my side mysql-devel was already installed but i also tried to reinstall it and it worked . – Mani Mar 14 '16 at 12:46
2

I wrote a blog post about this long ago. Sorry for plugging ;-)

The answer is to run

gem install mysql -- --with-mysql-conf=/usr/bin/mysql --with-mysql-lib=/usr/lib/mysql

You would have to use the lib64 path, obviously. Maybe this'll help you too.

You might want to know there is a ruby-mysql package in EPEL though. Might be interesting to look at that :)

wzzrd
  • 10,409
  • 2
  • 35
  • 47
1

try this:

1. yum uninstall mysql
2. yum install mysql
3. yum install mysql-devel (to install development libraries, For Debian, Knoppix, Buildix user apt-get install libmysqlclient15-dev)
4. gem install mysql
Istvan
  • 2,582
  • 3
  • 22
  • 29
0

In my scenario it worked

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Mani
  • 103
  • 5
Rajat
  • 3,349
  • 22
  • 29
  • I tried. Didn't work. Thanks though. –  Aug 15 '09 at 19:38
  • It worked for me without `sudo`. I also had to remember to put the version number in (`gem install mysql -v2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config`) – mwfearnley Nov 23 '16 at 11:02
0

I ran into the same problem as you described. Managed to fix it by doing the following (as root of course):

cd /usr/lib64
ln -nfs /usr/lib64/mysql/libmysqlclient.so.15 libmysqlclient.so
ldconfig

After that I was able to simply run gem install mysql and it all just worked.

Hope this helps!