Error while installing mysql2 gem on Ubuntu 12.04

This week I have install ubuntu 12.04 .When install on gem install mysql2 -v ‘0.3.11’ I got this error.

“ERROR:  Error installing mysql2:
ERROR: Failed to build gem native extension.

/home/salayhin/.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_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
checking for main() in -lmygcc… 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.”

Here is the solution I found.

To solve this error on ubuntu 12.04 , just install libmysqlclient-dev package using:

sudo apt-get install libmysqlclient-dev

and then:

gem install mysql2 -v '0.3.11'

It will be installed without any error.

Enjoy … Happy Coding 🙂

Advertisements

3 thoughts on “Error while installing mysql2 gem on Ubuntu 12.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s