# How to connect mysql whit Ruby

**URL:** <https://www.ruby-forum.com/t/how-to-connect-mysql-whit-ruby/90043>\
**Category:** Rails\
**Created:** [March 25, 2007, 2:58pm UTC](https://www.ruby-forum.com/t/how-to-connect-mysql-whit-ruby/90043 "2007-03-25T14:58:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@marco](https://www.ruby-forum.com/u/marco)\
**Post date:** [March 25, 2007, 2:58pm UTC](https://www.ruby-forum.com/t/how-to-connect-mysql-whit-ruby/90043/1 "2007-03-25T14:58:11Z")

</div>

Hi !

I am a newbie !

I want to use scaffold !

I dont know if I undestand everything right !

1. create table in mysql (I use mysql query browser)

2. set config/database.yml

* * *

## adapter: mysql database: hms host: 127.0.0.1 username: root password: socket: /var/run/mysqld/mysqld.sock

1. rails ruby script/generate scaffold link Admin

* * *

## tulap@Yumi:~/rails/howmanystep$ ruby script/generate scaffold linkP Admin exists app/controllers/ exists app/helpers/ exists app/views/admin exists app/views/layouts/ exists test/functional/ dependency model exists app/models/ exists test/unit/ exists test/fixtures/ identical app/models/link\_p.rb identical test/unit/link\_p\_test.rb identical test/fixtures/link\_ps.yml error Before updating scaffolding from new DB schema, try creating a table for your model (LinkP)

Where is my error ?

Thanks !!!

M.

---

<div class="post-metadata">

**Author:** ![marco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@marco](https://www.ruby-forum.com/u/marco)\
**Post date:** [March 25, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/how-to-connect-mysql-whit-ruby/90043/2 "2007-03-25T15:06:12Z")

</div>

Marco wrote:

> 1. set config/database.yml
> 2. rails ruby script/generate scaffold link Admin  
> dependency model
> 
> Where is my error ?
> 
> Thanks !!!
> 
> M.

Hi Marco,

You need to create a model and a table for it before you can generate a  
scaffold for it. I would recommend that you follow one of the many  
online tutorials for Ruby on Rails. Do let us know if you have trouble  
finding a good one - I think there’s one called Rollin on Rails on  
[onLamp.com](http://onLamp.com) but I don’t have the link handy - Google should be able to  
find it for you.

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![marco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@marco](https://www.ruby-forum.com/u/marco)\
**Post date:** [March 25, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/how-to-connect-mysql-whit-ruby/90043/3 "2007-03-25T16:34:22Z")

</div>

I am still follow the book …

But I doesnt undestand the file /sql/create.sql

This is the model ?

how to create this from phpmysql or from mysql query browser?

Thanks

---

<div class="post-metadata">

**Author:** ![marco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@marco](https://www.ruby-forum.com/u/marco)\
**Post date:** [March 25, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/how-to-connect-mysql-whit-ruby/90043/4 "2007-03-25T20:12:57Z")

</div>

On Mar 25, 8:32 am, “Marco” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am still follow the book …
> 
> But I doesnt undestand the file /sql/create.sql

Hi, Marco.

If by the book you mean Agile Web Dev, you should get the second  
edition or read up on migrations – it’s a much more elegant and  
useful way to create your db than using .sql files.

That said, could you post the error messages you get when you try to  
import the .sql file and the contents of the file? Perhaps there’s a  
typo that new eyes will spot.
