MySQL setup question

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

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

-sunny
http://ezror.com

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs