Forum: Ruby on Rails Connect Ruby on rails to MySQL

6335c9913604bbe6232badf05c8a9b87?d=identicon&s=25 Nik Kumar (student123)
on 2009-06-15 00:23
Can anyone please give the steps(commands) how to connect ruby on rails
to MySQl in fedora8.

I have installed MySQL and Ruby in my system.

Please specify any further installations to be done

Reply will be appreciated.
1dddc4b6c57e369dab7ad1d2e262dab7?d=identicon&s=25 Le Sa (tivrfoa)
on 2009-06-15 07:09
Nik Kumar wrote:
> Can anyone please give the steps(commands) how to connect ruby on rails
> to MySQl in fedora8.
>
> I have installed MySQL and Ruby in my system.
>
> Please specify any further installations to be done
>
> Reply will be appreciated.

http://www.google.com/search?q=rails+mysql
I'm not sure if it's the same for all OS, but you can try this:
your_app/config/database.yml

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: mysql
  database: your_database
  username: user
  password: password

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: your_database_test
  username: user
  password: password

production:
  adapter: mysql
  database: your_database_production
  username: user
  password: password
29ebf90af6107d2eb39b587c7972639c?d=identicon&s=25 Mukund (Guest)
on 2009-06-15 07:58
(Received via mailing list)
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>
6335c9913604bbe6232badf05c8a9b87?d=identicon&s=25 Nik Kumar (student123)
on 2009-06-15 11:03
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.
6335c9913604bbe6232badf05c8a9b87?d=identicon&s=25 Nik Kumar (student123)
on 2009-06-15 11:04
Le Sa wrote:
> Nik Kumar wrote:
>> Can anyone please give the steps(commands) how to connect ruby on rails
>> to MySQl in fedora8.
>>
>> I have installed MySQL and Ruby in my system.
>>
>> Please specify any further installations to be done
>>
>> Reply will be appreciated.
>
> http://www.google.com/search?q=rails+mysql
> I'm not sure if it's the same for all OS, but you can try this:
> your_app/config/database.yml
>
> # SQLite version 3.x
> #   gem install sqlite3-ruby (not necessary on OS X Leopard)
> development:
>   adapter: mysql
>   database: your_database
>   username: user
>   password: password
>
> # Warning: The database defined as "test" will be erased and
> # re-generated from your development database when you run "rake".
> # Do not set this db to the same as development or production.
> test:
>   adapter: mysql
>   database: your_database_test
>   username: user
>   password: password
>
> production:
>   adapter: mysql
>   database: your_database_production
>   username: user
>   password: password

I have tried this in my system(fedora 8) and I am getting this error

[root@xenhost]# SQLite version 3.x
bash: SQLite: command not found
[root@xenhost]# gem install sqlite3-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb
checking for fdatasync() in -lrt... no
checking for sqlite3.h... no

make
make: *** No rule to make target `ruby.h', needed by
`sqlite3_api_wrap.o'.  Stop.


Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
401a750effbc2448f54ce4cef5f5684b?d=identicon&s=25 amit kumar (Guest)
on 2009-06-15 11:40
(Received via mailing list)
NIk,

Are all these installed on your pc:  *libdbd-sqlite3-ruby sqlite3
libsqlite3-dev libsqlite3-ruby*

2009/6/15 Nik Kumar <rails-mailing-list@andreas-s.net>

> >> Reply will be appreciated.
> >   username: user
> >
> [root@xenhost]# gem install sqlite3-ruby
> `sqlite3_api_wrap.o'.  Stop.
>
--
Regards,

Amit Kumar
Sr. Software Engrr
+91 9890654102
+91 9373087399
Blogsite: http://amitbaraik.blog.co.in/
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2009-06-16 05:10
(Received via mailing list)
On Mon, Jun 15, 2009 at 2:04 AM, Nik
Kumar<rails-mailing-list@andreas-s.net> wrote:

> I have tried this in my system(fedora 8) and I am getting this error
>
> [root@xenhost]# SQLite version 3.x
> bash: SQLite: command not found
> [root@xenhost]# gem install sqlite3-ruby

Why are you doing this if you want to use MySQL?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
F3686edacbc9b902846e0f559857b5e0?d=identicon&s=25 juanmac (Guest)
on 2009-06-16 17:40
(Received via mailing list)
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

:)

On Jun 15, 11:03 am, Nik Kumar <rails-mailing-l...@andreas-s.net>
B6a2e2c1454c56eb686c5a38b5f73d02?d=identicon&s=25 Joel Dezenzio (elricstorm)
on 2009-06-16 18:25
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.
6335c9913604bbe6232badf05c8a9b87?d=identicon&s=25 Nik Kumar (student123)
on 2009-06-19 23:39
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
6335c9913604bbe6232badf05c8a9b87?d=identicon&s=25 Nik Kumar (student123)
on 2009-06-20 01:37
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)
7ff1b5523a2e105b3d781cc5380899e5?d=identicon&s=25 Michael R. (michael_r)
on 2010-11-04 23:43
Nik Kumar wrote in post #826714:
> Can anyone please give the steps(commands) how to connect ruby on rails
> to MySQl in fedora8.
>
> I have installed MySQL and Ruby in my system.
>
> Please specify any further installations to be done
>
> Reply will be appreciated.

Set MySQL from the start

$ rails -d mysql app_name
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.