Newbie trying to set up rails with MySQL

Hello –

Please pardon my newness – I’m just getting started with rails, and
I’m having some difficulty getting it set up with MySQL.

I am able to get the basic ruby server running (script\server). When I
created a new page (using script/generate controller about index), I
am not able to navigate to the new page, and Ruby either crashes or
gives me an error:

/!\ FAILSAFE /!\ Tue Jun 15 13:53:08 -0700 2010
Status: 500 Internal Server Error
Access denied for user ‘root’@‘localhost’ (using password: NO)

I have modified the database.yml file (full text of file pasted
below). I know the password is correct, as it is what I use to launch
mysql. When I enter ‘show databases’ into MySQL monitor, I see the two
databases I specified (emporium_development and emporium_test). The
MySQL service is running (I’m on Win7). I have tried both restarting
the MySQL service and restarting the ruby server. I created the
project with the command: ‘rails emporium -d mysql’ and prior to that,
I installed the mysql driver for rails using the command ‘gem install
mysql’. I installed the 105.4 MB mysql from here:
http://dev.mysql.com/downloads/mysql/5.1.html#downloads, but I have
not installed anything else (outside of rails).

Thank you for any help you can offer!!
Sarah

database.yml:

MySQL. Versions 4.1 and 5.0 are recommended.

Install the MySQL driver:

gem install mysql

On Mac OS X:

sudo gem install mysql – --with-mysql-dir=/usr/local/mysql

On Mac OS X Leopard:

sudo env ARCHFLAGS=“-arch i386” gem install mysql – --with-mysql-

config=/usr/local/mysql/bin/mysql_config

This sets the ARCHFLAGS environment variable to your native

architecture

On Windows:

gem install mysql

Choose the win32 build.

Install MySQL and put its /bin directory on your path.

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development: adapter: mysql
encoding: utf8
reconnect: false
database: emporium_development
pool: 5
username: root
password: hacked
host: localhost

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: mysql
encoding: utf8
reconnect: false
database: emporium_test
pool: 5
username: root
password: hacked
host: localhost

Full Error Text:
C:\webapp\emporium>ruby script\server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-06-15 13:52:56] INFO WEBrick 1.3.1
[2010-06-15 13:52:56] INFO ruby 1.8.6 (2010-02-04) [i386-mingw32]
[2010-06-15 13:52:56] INFO WEBrick::HTTPServer#start: pid=3664
port=3000
/!\ FAILSAFE /!\ Tue Jun 15 13:53:04 -0700 2010
Status: 500 Internal Server Error
Access denied for user ‘root’@‘localhost’ (using password: NO)
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/mysql_adapter.rb:619:in real_connect' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/mysql_adapter.rb:619:in connect’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/mysql_adapter.rb:203:in initialize' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/mysql_adapter.rb:75:in new’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/mysql_adapter.rb:75:in mysql_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:223:in send’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:223:in new_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:245:in checkout_new_connection’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:188:in checkout' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:184:in loop’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:184:in checkout' C:/Ruby186/lib/ruby/1.8/monitor.rb:242:in synchronize’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:183:in checkout' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:98:in connection’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:326:in
retrieve_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_specification.rb:123:in retrieve_connection’

C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/

active_record/conne
ction_adapters/abstract/connection_specification.rb:115:in
connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/query _cache.rb:9:in cache’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/query
_cache.rb:28:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:361:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/
action_controller/str
ing_coercion.rb:25:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/
methodoverride.rb:24:i
n call' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/par ams_parser.rb:15:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/
action_controller/ses
sion/cookie_store.rb:99:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/fai lsafe.rb:26:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:
11:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb: 11:in synchro
nize’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:
11:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dis patcher.rb:114:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/
action_controller/rel
oader.rb:34:in run' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dis patcher.rb:108:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/
static.rb:31:in
call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb: 47:in call’

C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:

41:in `each’

C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:

41:in `call’

C:/Ruby186/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/

log_tailer.rb:1
7:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/ content_length.rb:13:i n call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/
webrick.rb:48:
in service' C:/Ruby186/lib/ruby/1.8/webrick/httpserver.rb:104:in service’
C:/Ruby186/lib/ruby/1.8/webrick/httpserver.rb:65:in run' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:173:in start_thread’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:162:in start' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:162:in start_thread’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:95:in start' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:92:in each’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:92:in start' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:23:in start’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:82:in start' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/ webrick.rb:14: in run’
C:/Ruby186/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/
server.rb:111
C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_orig inal_require' C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require’

script/server:3

/!\ FAILSAFE /!\ Tue Jun 15 13:53:08 -0700 2010
Status: 500 Internal Server Error
Access denied for user ‘root’@‘localhost’ (using password: NO)
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/mysql_adapter.rb:619:in real_connect' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/mysql_adapter.rb:619:in connect’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/mysql_adapter.rb:203:in initialize' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/mysql_adapter.rb:75:in new’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/mysql_adapter.rb:75:in mysql_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:223:in send’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:223:in new_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:245:in checkout_new_connection’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:188:in checkout' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:184:in loop’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:184:in checkout' C:/Ruby186/lib/ruby/1.8/monitor.rb:242:in synchronize’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:183:in checkout' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:98:in connection’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/conne
ction_adapters/abstract/connection_pool.rb:326:in
retrieve_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_specification.rb:123:in retrieve_connection’

C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/

active_record/conne
ction_adapters/abstract/connection_specification.rb:115:in
connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/query _cache.rb:9:in cache’
C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/query
_cache.rb:28:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/ active_record/conne ction_adapters/abstract/connection_pool.rb:361:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/
action_controller/str
ing_coercion.rb:25:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/
methodoverride.rb:24:i
n call' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/par ams_parser.rb:15:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/
action_controller/ses
sion/cookie_store.rb:99:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/fai lsafe.rb:26:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:
11:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb: 11:in synchro
nize’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:
11:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dis patcher.rb:114:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/
action_controller/rel
oader.rb:34:in run' C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/ action_controller/dis patcher.rb:108:in call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/
static.rb:31:in
call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb: 47:in call’

C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:

41:in `each’

C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:

41:in `call’

C:/Ruby186/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/

log_tailer.rb:1
7:in call' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/ content_length.rb:13:i n call’
C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/
webrick.rb:48:
in service' C:/Ruby186/lib/ruby/1.8/webrick/httpserver.rb:104:in service’
C:/Ruby186/lib/ruby/1.8/webrick/httpserver.rb:65:in run' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:173:in start_thread’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:162:in start' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:162:in start_thread’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:95:in start' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:92:in each’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:92:in start' C:/Ruby186/lib/ruby/1.8/webrick/server.rb:23:in start’
C:/Ruby186/lib/ruby/1.8/webrick/server.rb:82:in start' C:/Ruby186/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/ webrick.rb:14: in run’
C:/Ruby186/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/
server.rb:111
C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_orig inal_require' C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require’

script/server:3

Yep,
my problems was almost the same! And still not workable with mysql, I
don"t know why. Please let me know if you have useful answer!
Thnaks,
gezope

On Jun 15, 11:13 pm, Sarah F. [email protected] wrote:

I’m on Win7
Last time I checked (which is at least 6 months ago now), the RoR
mysql adapter and mysql 5.1 did not play well together on Vista/Win7.
You may want to try version 5.0 before anything else.

I did the same for XP, I installed 5.0

This link my give some additional help:

JRuby works without any problem (at least with XP) since is using the
Jdbc adapter, but probably you want to use C Ruby.

The problem is usually the dll and you could try this dll from
instantrails:
http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/

As you know Ruby works better on Unix (Matz words) so if you can use
Ubuntu or a Mac. After many complaints, at work, I managed to get a
Mac and now I am really happy about my dev environment. If I where
still in Windows, probably now I would be using JRuby for sure.