MySQL binding problem on Max OS X 10.4

Hi all.

No matter what I do I can’t get rails to see my MySQL database. All
details are below. I really appreciate any assistance. Thanks!!!


  1. I’m using Rails 1.1.4 with Ruby 1.8.4 on Mac OS X 10.4.7. I have
    installed the MySQL bindings following the instructions here:

This seemed to make and install properly.

  1. My database is working fine, with schema names per the convention and
    matching database.yml:

adapter: mysql
database: test_v1_development
username: root
password: *****
host: localhost

  1. I put the following code into the environment.rb file in the
    Rails::Initializer section:

test database

printf “Establishing DB connection…”
puts “ok!”

puts “Testing DB connection …”
tables = ActiveRecord::Base.connection.select_all(‘SHOW TABLES’)
rescue => err
puts ‘===== database connection failed =====’
puts “Missing database bindings for #{err.blamed_files}” if err.message
=~ /^uninitialized constant Mysql$/
puts “Database tested OK, found #{tables.size} tables”

  1. When I start the WEBrick server I get the following error:

Establishing DB
establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified) from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:185:inestablish_connection’
from ./script/…/config/…/config/environment.rb:16
run' from ./script/../config/../config/environment.rb:13 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
require' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:52 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
require' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from ./script/server:3
from -e:4

Dennis, thanks for your suggestions. Unfortunately, I tried both with no
success. Get the same error as in my original post.


Two quick suggestions:

Have you tried accessing MySQL through the local socket file:

adapter: mysql
database: dev
username: dev
password: dev
socket: /tmp/mysql.sock

If you intend on using a hostname then try specifying a port:

adapter: mysql
database: test_v1_development
username: root
password: *****
host: localhost
port: 3306

I’m not certain if the port is mandatory, but I always specify it when
using a hostname.


I can recreate this same error on my Mac if I completely remove the
line. So I think this might be something in the format of your
database.ymlfile. You might want to check your indents and spacing,
especially that
there is a space between adapter: and mysql.


Well, now that I reread your problem description, it may be that you put

   puts "Missing database bindings for #{err.blamed_files}" if

=~ /^uninitialized constant Mysql$/
puts “Database tested OK, found #{tables.size} tables”

inside the Rails::Initializer block. It can’t go there. It has to be at
end of the file, after this comment:

Include your application configuration below


Thanks for the suggestion, Jeff. My database.yml is unchanged from the
stub installed by Rails when I created the application. However, I did
try removing tabs and replacing them with spaces, removing all spaces,
etc., and ensured there was a space between the colon and the adapter
name. No success.

If you can post the text of your database.yml file, though, I can try
copying and pasting to see if that fixes the problem.


Jeff, I tried that originally and the test never ran at all.

I’ve done some more testing and even more stumped than ever.

I created a brand new application and a new database schema. One table
and a scaffold controller. Works!

Then I copied the database.yml and environment.rb from the new, working
application to the broken one. Changed the schema name in database.yml.

Still doesn’t work. (Note that my debugging code is no longer in
environment.rb, so I’m judging the failure from a more prosaic “You have
a nil object when you didn’t expect it!” error generated by a

However, you have inspired me to check and see if the problem is
elsewhere. Perhaps the error I first reported was a red herring caused
by the debug code being in the wrong place in environment.rb. I’ll look
into this further and see if my problems really lie with a missing



Problem solved, but in the worst kind of engineering way: I don’t know

I recreated the application, following the steps I used for the simple
test referred to in the previous item. Everything works. I’ll just
modify from here and see if any one step causes the problem I saw

I guess the one take-away is that I should not over-configure a new
application without testing its connectivity with a simple framework

Thanks for your input, everyone.


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