Connect Ruby on rails to MySQL

Install the following gems.

1) Rails
2) MySQL (try sudo gem install mysql -- --with-mysql-config=/usr/bin/
mysql-config if the normal sudo gem install mysql fails)

Once both of those are successful, you can configure database.yml to
point to a valid schema a try it out.

Mukund wrote:

Install the following gems.

1) Rails
2) MySQL (try sudo gem install mysql -- --with-mysql-config=/usr/bin/
mysql-config if the normal sudo gem install mysql fails)

Once both of those are successful, you can configure database.yml to
point to a valid schema a try it out.

On Jun 15, 3:23�am, Nik Kumar <rails-mailing-l...@andreas-s.net>

Thanks to ur reply..

One more question is how to configure database.yml.

Nik, Le Sa had explained you how to configure the databases.yml.

Follow his instructions, but keep in mind that you would have to
configure the socket (if your mySQL server have one) and maybe your
mySQL host and port. For development and testing environment you
should use sqlite but in production you'll like a more robust database
engine.

Sample configuration for a production environment:

production:
  adapter: mysql
  database: your_database_production
  username: your_mySQL_user
  password: your_mySQL_password
  socket: /path/to/your/socket
  host: /your/mySQL/host (probably localhost)
  port: your_mySQL_port

:slight_smile:

Let's go back to the beginning here..

First, you said you are using redhat and you said you already have mysql
installed and rails installed. In that case you just need to have the
gem installed.

The gem is the hard part, depending on which "ruby" version you are
using. So, try the following first:

sudo gem install mysql

.. if you get failures installing that gem and you are using ruby 1.9.x
..

Do..

sudo gem install hectoregm-mysql-ruby

Once any of those gems installs.. test to make sure it works..

Run IRB

type require 'mysql'

The output should show => True

....

If you get this far then you just need to create your new project and
specify that you want to use mysql. You can do this a few ways. First
way is if you have a really good IDE (the IDE will do it for you when
you create your project (netbeans for example does this). The second
way is to specify your database in the database.yml file.

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: name_of_your_database_here
  pool: 5
  username: root
  password:
  host: localhost

Then you need to run a rake DB create task to create the database based
on the specifications of the database.yml file.

rake db:create (which works for the current environment database
specified)
.. or ..
rake db:create:all (which creates all databases specified in
database.yml)

Hope that helps.

Thank u Älphä Blüë
I have a doubt please clarify..
How do we know the contents of the database.yml file.
does this command is the right one to use $vim /configure/database.yml

One more thing I am getting this thing if i go for rake

$rake db:migrate

rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb,
Rakefile.rb)
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2377:in
`raw_load_rakefile'
(See full trace by running task with --trace)