Installing Mysql gem on CentOS

Migrating from Debian to CentOS was certainly not pleasant one. But slowly I am getting used to yum (I still miss my apt). Recently I faced an issue installing mysql gem. Here is short description of problem followed by solution.

[root@VMVSOCT02 /]# gem install mysql
Need to update 0 gems from http://gems.rubyforge.org

complete
Select which gem to install for your platform (i386-linux)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 3
Building native extensions. This could take a while…

ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby 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

Installation Steps


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
[root@VMVSOCT02 /]# gem install mysql
Need to update 1 gems from http://gems.rubyforge.org
.
complete
Select which gem to install for your platform (i386-linux)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 3
Building native extensions. This could take a while…
Successfully installed mysql-2.7

Create database users
octopus/octopus
grant permission on octopus_development, octopus_test

Advertisements

~ by sxm20 on May 17, 2007.

17 Responses to “Installing Mysql gem on CentOS”

  1. Hi,

    I follow your step but still get the same error message. Any suggestion?

  2. Did you check your mkmf.log file. This error is usually caused by not having all the dependencies fulfilled or have a wrong version.

  3. @winson: try doing this on a fresh CentOS v5 base install:

    $ sudo yum install gcc mysql mysql-devel
    $ sudo gem install mysql -- \
    --with-mysql-include=/usr/include/mysql \
    --with-mysql-lib=/usr/lib/mysql

  4. @nippleequality – your suggestion fixed my problem too! Thanks.

  5. @nippleequality – thank you so much! Everywhere I looked for this answer, people only gave the lib option, I never even thought to use the include as well – totally solved my problem!

  6. I had this problem, and I found out the solution here:

    http://forums.mysql.com/read.php?116,178217,201272#msg-201272

    I just needed to install libmysqlclient15-dev

  7. nippleequality – you rock very hard. I could not get this bugger installed on CentOS at all – till I tried your instructions. Major respect!

  8. @nippleequality – Yet another thank you! Worked perfectly.

  9. one more “thank you” to @nippleequality 🙂

  10. Thanks, big help.

  11. May seem obvious to some, but if you’ve installed the 64-bit package, you need to install the gem with –with-mysql-lib=/usr/lib64/mysql instead

  12. major thanks.

  13. […] Install MySQL Gem Faild for me, so i found here the solution: mysql gem on centos […]

  14. Interestingly, this same error is produced if gcc is not installed (since the gem installation relies on gcc to test for the availability of the libraries and includes). I fixed this on Centos 5 with

    # yum install gcc
    # gem install mysql — –with-mysql-config=/usr/bin/mysql_config

  15. thanks…. !
    centos ovh plesk

  16. […] Sudo gem install mysql, mysql-devel problems in CentOs By torsd Installing Mysql gem on CentOS […]

  17. Fixed my problem too. Thanks!

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

 
%d bloggers like this: