Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get rails running with mysql - rake db:create produces error

Posted on 2009-05-07
7
Medium Priority
?
1,167 Views
Last Modified: 2013-12-05
Hi, I try to study rails and follow the tutorial
http://guides.rubyonrails.org/getting_started.html#hello-rails

At the point 3.4 where it says creating the database, i type

rake db:create

and it tells me:

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql

when I do

gem install mysql

as suggested, it quits with:

WARNING:  Installing to ~/.gem since /usr/lib/ruby/gems/1.8 and
          /usr/bin aren't both writable.                      
WARNING:  You don't have /home/klaus/.gem/ruby/1.8/bin in your PATH,
          gem executables will not run.                            
Building native extensions.  This could take a while...            
ERROR:  Error installing mysql:                                    
        ERROR: Failed to build gem native extension.                

/usr/bin/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.

- - -

What am I missing here, what could probably be wrong?
0
Comment
Question by:xberry
  • 4
  • 2
7 Comments
 
LVL 10

Assisted Solution

by:mahome
mahome earned 400 total points
ID: 24325467
How did you install Rails?
0
 
LVL 14

Author Comment

by:xberry
ID: 24325832
>> How did you install Rails?

beats me, i should have kept a log how i did perform that exactly ...
Actually I followed an other tutorial, (can't tell you exactly which)
but basically I first installed ruby, then rubygems, then
gem install rails - only those steps I did as superuser/root.
Also I did install the passenger, i.e prepare modules and else for use with apache

sorry, it doesn't sound really professional, but I understood that with rails I could
take things more easy, light so to say but installations and preparations obviously are
harder than with other environments ? ...
0
 
LVL 12

Assisted Solution

by:cminear
cminear earned 200 total points
ID: 24326373
Try the following commands:
   which ruby
   which rails
   which gem
   which mysqladmin
All four should return the locations of those executables.  But right now, my best guess is that MySQL is not installed on this system (and this would be hinted by the last command not finding 'mysqladmin').  Also look for libmysqlclient.so in /usr/lib.  If it's not there, but you are certain that MySQL is installed on your server?  If the database is running on another system, you will still need the mysql client libraries in order to access it remotely.

Once the MySQL situation is sorted out, you may want to do the 'gem install mysql' as root, so that it is installed in the system ruby directory rather than your home directory (where it would be harder for a deployed Rails app to find it).
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 10

Expert Comment

by:mahome
ID: 24326439
It's OK. I dind't succeed at all with the sources. I had the luck that ubuntu has a ready package.

I think you have to execute the command with sudo / as root and follow the instructions here http://blog.wearesakuzaku.com/installing-the-mysql-ruby-gem-on-os-x/. This seems to be a similar problem.

0
 
LVL 14

Author Comment

by:xberry
ID: 24326660
Try the following commands:
   which ruby
   which rails
   which gem
   which mysqladmin

only which gems returns:

which: no gems in (/home/klaus/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin)

everything else (ruby/rails/mysql) is installed in
/usr/bin

locate libmysqlclient.so returns

/usr/lib/libmysqlclient.so.15
/usr/lib/libmysqlclient.so.15.0.0
/usr/lib/mysql/libmysqlclient.so.15
/usr/lib/mysql/libmysqlclient.so.15.0.0

mysql is definitely installed on my system, funnywise the 'test' database that it announces in
database.yml gets installed in MYSQL as i found out with my phpMyAdmin, if this 'test db is
not created by any other application?  
0
 
LVL 14

Author Comment

by:xberry
ID: 24333513
@cminear:

it is

which gem, not which gems

so gem is installed, too in /usr/bin

@mahome:

>> follow the instructions here http://blog.wearesakuzaku.com/installing-the-mysql-ruby-gem-on-os-x/. This seems to >> be a similar problem.

difficult to follow the instructions there, since I don't have a mysql_config file anywhere in my system,
also, my mysql is installed in /usr/bin and libraries
in /usr/lib and some other things in /usr/share.
Is it a mistake that it is not installed in /usr/local ?
0
 
LVL 14

Accepted Solution

by:
xberry earned 0 total points
ID: 24333842
Solved it!!!

Went into YAST Software manager and did a search for all 'ruby' packages.
Installed then a package ruby-mysql, which are ruby mysql bindings. Then
I did repeat the step with rake db:create and went without fail.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question