Rails (and MySQL) on Linux - gem install mysql

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
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

Hi,

Do you have the MySQL development library installed?

2007/11/12, Onno van der Straaten [email protected]:

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

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 and foundtwo rpm’s
SuSE 10.X 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-
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.” [email protected]

Instructions to fix this are here:

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

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

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 #

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