Solved

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

Posted on 2009-05-07
7
1,152 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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