# MySQL setup question

**URL:** <https://www.ruby-forum.com/t/mysql-setup-question/195902>\
**Category:** Rails\
**Created:** [October 2, 2010, 1:24pm UTC](https://www.ruby-forum.com/t/mysql-setup-question/195902 "2010-10-02T13:24:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [October 2, 2010, 1:24pm UTC](https://www.ruby-forum.com/t/mysql-setup-question/195902/1 "2010-10-02T13:24:11Z")

</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:  
adapter: mysql  
encoding: utf8  
database: blog  
pool: 5  
username: root  
password:  
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  
// 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!!

Greetings, Daniel

---

<div class="post-metadata">

**Author:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [October 3, 2010, 3:13pm UTC](https://www.ruby-forum.com/t/mysql-setup-question/195902/2 "2010-10-03T15:13:18Z")

</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:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [October 3, 2010, 7:13pm UTC](https://www.ruby-forum.com/t/mysql-setup-question/195902/3 "2010-10-03T19:13:15Z")

</div>

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

> > 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:** ![dazuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@dazuma](https://www.ruby-forum.com/u/dazuma)\
**Post date:** [October 4, 2010, 6:36pm UTC](https://www.ruby-forum.com/t/mysql-setup-question/195902/4 "2010-10-04T18:36:04Z")

</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  
> > 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
