Home > Technology > gem install mysql

gem install mysql

If you attempt to
gem install mysql
and run into errors that look like this…


/usr/bin/ruby1.8 extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
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... yes
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.
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

Its probably because it can’t find your mysql_config.

Now usually you can solve this by simply running it again in this fashion

gem install mysql -- --with-mysql-config=/path/to/mysql_config

However if this is a box you built yourself from scratch and added the pieces you needed as you went along, chances are you’re missing a library.

So run the following

root@Aesun:/usr# apt-get install libmysqlclient
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package libmysqlclient
root@Aesun:/usr# apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libmysqlclient-dev is a virtual package provided by:
libmysqlclient15-dev 5.0.51a-3ubuntu5.4
You should explicitly select one to install.

Now pick the one it gives you – unless ofcourse your version of MySQL is different etc. etc.

root@Aesun:/usr# apt-get install libmysqlclient15-dev

and voila!

root@Aesun:/usr# gem install mysql
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed

Categories: Technology Tags: , , ,