Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-07
7
Medium Priority
?
1,165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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