Solved

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

Posted on 2009-05-07
7
1,147 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 100 total points
Comment Utility
How did you install Rails?
0
 
LVL 14

Author Comment

by:xberry
Comment Utility
>> 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 50 total points
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 10

Expert Comment

by:mahome
Comment Utility
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
Comment Utility
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
Comment Utility
@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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now