Solved

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

Posted on 2009-05-07
7
1,150 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
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 50 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
A short film showing how OnPage and Connectwise integration works.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

18 Experts available now in Live!

Get 1:1 Help Now