# MySQL setup question

**URL:** <https://discuss.rubyonrails.org/t/mysql-setup-question/54787>\
**Category:** rubyonrails-talk\
**Created:** [October 2, 2010, 11:23am UTC](https://discuss.rubyonrails.org/t/mysql-setup-question/54787 "2010-10-02T11:23:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Amsterdam](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@Daniel\_Amsterdam](https://discuss.rubyonrails.org/u/Daniel_Amsterdam)\
**Post date:** [October 2, 2010, 11:23am UTC](https://discuss.rubyonrails.org/t/mysql-setup-question/54787/1 "2010-10-02T11:23:16Z")

</div>

Hello,

I'm new to ror and i really like it so far! for a new application i would like to setup a ror application connecting to mysql but i can't figure it out how. rails works fine with sqllite out the box but i need it working with mysql. these are my versions:

-OSX snow leopard -ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] -Rails 3.0.0 $ /usr/local/mysql/bin/mysql : Server version: 5.1.51 MySQL Community Server (GPL) $ gem list: mysql (2.8.1)

this is my development setting in config/database.yml

development: &nbsp;&nbsp;&nbsp;&nbsp;adapter: mysql &nbsp;&nbsp;&nbsp;&nbsp;encoding: utf8 &nbsp;&nbsp;&nbsp;&nbsp;database: blog &nbsp;&nbsp;&nbsp;&nbsp;pool: 5 &nbsp;&nbsp;&nbsp;&nbsp;username: root &nbsp;&nbsp;&nbsp;&nbsp;password: &nbsp;&nbsp;&nbsp;&nbsp;socket: /tmp/mysql.sock

Now when i test rake db:migrate i get the folowing error:

daniels-macbook:blog daniel$ rails generate scaffold post name:string message:text &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// files created .... daniels-macbook:blog daniel$ rake db:migrate (in /sites/blog) rake aborted! !!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql', '2.8.1'

(See full trace by running task with --trace)

---

<div class="post-metadata">

**Author:** ![senthilnambi](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@senthilnambi](https://discuss.rubyonrails.org/u/senthilnambi)\
**Post date:** [October 3, 2010, 9:42am UTC](https://discuss.rubyonrails.org/t/mysql-setup-question/54787/2 "2010-10-03T09:42:38Z")

</div>

A shot in the dark, is the socket location correct? Try entering into mysql via command link using that socket.

-sunny [http://ezror.com](http://ezror.com)

---

<div class="post-metadata">

**Author:** ![radhames\_brito](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@radhames\_brito](https://discuss.rubyonrails.org/u/radhames_brito)\
**Post date:** [October 3, 2010, 5:11pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-question/54787/3 "2010-10-03T17:11:54Z")

</div>

> ```
> // files created ....
> 
> ```

> > daniels-macbook:blog daniel$ rake db:migrate
> 
> > (in /sites/blog)
> 
> > rake aborted!
> 
> > !!! Missing the mysql gem. Add it to your Gemfile: gem ‘mysql’,
> 
> > ‘2.8.1’
> 
> > 
> 
> > (See full trace by running task with --trace)
> 
> > * * *
> 
> > 
> 
> > The mysql 2.8.1 is already in my gem list and i have the gem installed
> 
> > with the command: sudo gem install mysql – --with-mysql-config=/usr/
> 
> > local/mysql/bin/mysql\_config
> 
> > 
> 
> > Does anyone know what i’m doing wrong? Thank you very much!!
> 
> >

Did you put it in your gemfile?

The gemfile is in the rails app root directory

---

<div class="post-metadata">

**Author:** ![Daniel\_Amsterdam1](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@Daniel\_Amsterdam1](https://discuss.rubyonrails.org/u/Daniel_Amsterdam1)\
**Post date:** [October 4, 2010, 4:35pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-question/54787/4 "2010-10-04T16:35:09Z")

</div>

The socket is ok, i use the socket in php and it works. I didn't put the gem in the gem list (i didn't know i had to do that so thank you for that) but when i put the gem in the list i get the error:

rake db:migrate (in /sites/mysqlapp) rake aborted! undefined method `init' for Mysql:Class

The gem doesn't work: $ irb\>\> require 'mysql' =\> true

> > db = Mysql.connect('localhost', 'root', '','blog')

NoMethodError: undefined method `connect' for Mysql:Class &nbsp;&nbsp;from (irb):2

when i google the "undefined method `init' for Mysql:Class" error i found a lot of users with the same problem.. To bad i couldn't find a working solution, i gues i have to stick to sqlite3.

Greetings
