# Database configuration

**URL:** <https://www.ruby-forum.com/t/database-configuration/142528>\
**Category:** Rails\
**Created:** [July 8, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/database-configuration/142528 "2008-07-08T22:06:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 8, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/database-configuration/142528/1 "2008-07-08T22:06:11Z")

</div>

# SQLite version 3.x

# gem install sqlite3-ruby (not necessary on OS X Leopard)

development:  
adapter: sqlite3  
database: db/development.sqlite3  
timeout: 5000

# 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: sqlite3  
database: db/test.sqlite3  
timeout: 5000

production:  
adapter: sqlite3  
database: db/production.sqlite3  
timeout: 5000

This is the database.yml file. I’m very new to RoR and I’m trying to set  
it up. In this file it has sqlite3… I’m using MySQl. What should I do?  
Also I can see that there are several databases, development, test,  
production. Do I need to create these databases? Tables?

Thanks!!

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 8, 2008, 10:41pm UTC](https://www.ruby-forum.com/t/database-configuration/142528/2 "2008-07-08T22:41:56Z")

</div>

Create your MySQL database, user, and grant access for that user. Change  
your database.yml to something like the following:

development:  
adapter: mysql  
encoding: utf8  
database: my\_db\_name  
username: my\_username  
password: my\_password  
host: localhost

You need at least a development database.

Hope this helps.

Phil

2008/7/9 Justin To [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> # Do not set this db to the same as development or production.
> 
> This is the database.yml file. I’m very new to RoR and I’m trying to set  
> it up. In this file it has sqlite3… I’m using MySQl. What should I do?  
> Also I can see that there are several databases, development, test,  
> production. Do I need to create these databases? Tables?
> 
> ## Thanks!!
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

## –

## Phil Calder removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 8, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/database-configuration/142528/3 "2008-07-08T23:00:58Z")

</div>

Ok, I got that part… now I need to try to create the scaffold:

./script/generate scaffold Foo somefieldname:integer  
anotherfieldname:string whateverfieldsyouwant:text

is what I found on  
[http://wiki.rubyonrails.org/rails/pages/ScaffoldGenerator](http://wiki.rubyonrails.org/rails/pages/ScaffoldGenerator)

What is ‘Foo’ and what’s the stuff after that for?

Thanks!

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 8, 2008, 11:25pm UTC](https://www.ruby-forum.com/t/database-configuration/142528/4 "2008-07-08T23:25:50Z")

</div>

Foo is the model you are creating (app/models/foo.rb).  
Rails will generate a migration to create a database table based on the  
parameters you supply. In this case the 2 fields (integer and text).

After generating the scaffold look in:  
db/migrations/001\_create\_foo.rb  
You can add more fields if you want, then run  
rake db:migrate

This creates the database table.

2008/7/9 Justin To [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 8, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/database-configuration/142528/5 "2008-07-08T23:44:23Z")

</div>

Phil Calder wrote:

> Foo is the model you are creating (app/models/foo.rb).

Foo is an arbitrary name, right? What is an example of a real model  
name?

> Rails will generate a migration to create a database table based on the  
> parameters you supply. In this case the 2 fields (integer and text).

I already have a database with two tables created, what do I do now?

> After generating the scaffold look in:  
> db/migrations/001\_create\_foo.rb  
> You can add more fields if you want, then run  
> rake db:migrate

In the command prompt, do I simply type ‘rake db:migrate’ or do I have  
to include a path? If I do, how would I specify the path? Using -c ?

> This creates the database table.
> 
> 2008/7/9 Justin To [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

Thanks!!
