# Rails (and MySQL) on Linux - gem install mysql

**URL:** <https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954>\
**Category:** Rails\
**Created:** [November 12, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954 "2007-11-12T15:07:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [November 12, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/1 "2007-11-12T15:07:09Z")

</div>

Hi,  
I could use some suggestions on how to get Rails running properly on a  
Linux vserver running SuSE Linux Enterprise Server 10.

The application is not working as expected, on certain requests the  
server dies. In the log file I see MySQL connection problems. I don’t  
have the MySQL gem installed so this is probably to be expected.

Assuming I really need this MySQL gem, the question is now how this  
can be installed?

gem install mysql is not working:  
user@epf:~\> sudo gem install mysql  
root’s password:  
Bulk updating Gem source index for: [http://gems.rubyforge.org](http://gems.rubyforge.org)  
Select which gem to install for your platform (x86\_64-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  
–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-config  
–without-mysql-config  
–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-mysqlclientlib  
–without-mysqlclientlib  
–with-mlib  
–without-mlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-zlib  
–without-zlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-socketlib  
–without-socketlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-nsllib  
–without-nsllib  
–with-mysqlclientlib  
–without-mysqlclientlib

In the readme of the gem some suggestions are offered for installing  
this. These also don’t work, for instance:  
ruby extconf.rb  
ruby extconf.rb --with-mysql-dir=/usr/bin  
ruby extconf.rb --without-mysqlclientlib

env LD\_RUN\_PATH=/usr/lib64/  
ruby extconf.rb

Thanks and Regards,  
Onno

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [November 12, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/2 "2007-11-12T15:14:46Z")

</div>

Hi,

Do you have the MySQL development library installed?

2007/11/12, Onno van der Straaten [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [November 12, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/3 "2007-11-12T15:30:38Z")

</div>

On 12 Nov 2007, at 14:06, Onno van der Straaten wrote:

> can be installed?
> 
> gem install mysql is not working:  
> user@epf:~\> sudo gem install mysql

Off the top of my head,

sudo gem install mysql – --with-mysql-dir=/usr/local/mysql

should work assuming /usr/local/mysql has an include folder with the  
headers and a lib folder with the libraries.

Fred

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [November 12, 2007, 3:44pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/4 "2007-11-12T15:44:42Z")

</div>

I’m not sure, because when I do this:  
rpm -ivh mysql-devel-5.0.26-14.x86\_64.rpm  
it reports and error:  
error: Failed dependencies:  
mysql-shared = 5.0.26 is needed by mysql-  
devel-5.0.26-14.x86\_64

I searched for ‘libmysqlclient.so’ on [rpm.pbone.net](http://rpm.pbone.net) and foundtwo rpm’s  
SuSE 10.X [ftp.suse.com/pub/update/10.2/rpm/x86\_64/mysql-](http://ftp.suse.com/pub/update/10.2/rpm/x86_64/mysql-)  
devel-5.0.26-14.x86\_64.rpm  
SuSE 10.X [ftp.suse.com/pub/update/10.1/rpm/x86\_64/mysql-](http://ftp.suse.com/pub/update/10.1/rpm/x86_64/mysql-)  
devel-5.0.26-12.13.x86\_64.rpm

So I tried the one with the highest version number.

But I think I have it installed because when I do a global find on  
‘libmysqlclient’ there are some hits:  
epf:/home/user/migration/soft # find / -name ‘libmysqlclient\*’  
/usr/lib64/mysql/libmysqlclient\_r.so.15.0.0  
/usr/lib64/mysql/libmysqlclient\_r.so.15  
/usr/lib64/mysql/libmysqlclient.so.15  
/usr/lib64/mysql/libmysqlclient.so.15.0.0  
/usr/lib64/libmysqlclient\_r.so.15.0.0  
/usr/lib64/libmysqlclient\_r.so.15  
/usr/lib64/libmysqlclient.so.15  
/usr/lib64/libmysqlclient.so.15.0.0

Thanks and Regards,  
Onno

On Nov 12, 3:14 pm, “Lutz H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [December 3, 2008, 6:15pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/5 "2008-12-03T18:15:57Z")

</div>

Instructions to fix this are here:

[http://articles.slicehost.com/2008/7/8/ubuntu-hardy-installing-mysql-with-rails-and-php-options](http://articles.slicehost.com/2008/7/8/ubuntu-hardy-installing-mysql-with-rails-and-php-options)

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [December 3, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/6 "2008-12-03T18:46:39Z")

</div>

On unix systems you can typically do “which mysql\_config” and you’ll  
find that the libraries are “$(which mysql\_config)/…/lib”.

Then you can use Fred’s tip and:

gem install mysql – --with-mysql-config=$(which mysql\_config)

Rick

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [November 12, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/7 "2007-11-12T15:48:12Z")

</div>

I’m not sure where my mysql dir is, the mysql exe is in /usr/bin and  
it fails when I provide that directory:  
epf:/home/user/migration/soft # sudo gem install mysql – --with-mysql-  
dir=/usr/bin  
Select which gem to install for your platform (x86\_64-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 – --with-mysql-dir=/usr/bin  
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  
–with-make-prog  
–without-make-prog  
–srcdir=.  
–curdir  
–ruby=/usr/bin/ruby  
–with-mysql-config  
–without-mysql-config  
–with-mysql-dir  
–with-mysql-include  
–without-mysql-include=${mysql-dir}/include  
–with-mysql-lib  
–without-mysql-lib=${mysql-dir}/lib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-mlib  
–without-mlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-zlib  
–without-zlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-socketlib  
–without-socketlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-nsllib  
–without-nsllib  
–with-mysqlclientlib  
–without-mysqlclientlib

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/  
mysql-2.7 for inspection.  
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem\_make.out  
epf:/home/user/migration/soft #

---

<div class="post-metadata">

**Author:** ![Onno\_van\_der\_Straat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/d6d6ee/32.png) [@Onno\_van\_der\_Straat](https://www.ruby-forum.com/u/Onno_van_der_Straat)\
**Post date:** [June 8, 2010, 12:29pm UTC](https://www.ruby-forum.com/t/rails-and-mysql-on-linux-gem-install-mysql/119954/8 "2010-06-08T12:29:40Z")

</div>

Hi,  
I am also getting same error. I tried all options but still error is  
there.  
Can anyone point me to correct answer?  
I don’t why the rails have this much of trouble.

Thanks,  
Tushar
