Connecting to mysql on OS X 10.4


#1

i have looked in the archives, i have the agile book, and its links
right in front of me, and i have done pretty much everything i can
think to do except start from a fresh OS install, and yet i still can
not get Rails to talk to MySQL.

when i try to do this:

237:/Library/WebServer/Documents/Rails/depot chris$ ruby script/
generate scaffold Product Admin

i get this output:

   exists  app/controllers/
   exists  app/helpers/
   exists  app/views/admin
   exists  test/functional/

dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/product.rb
identical test/unit/product_test.rb
identical test/fixtures/products.yml
Access denied for user: ‘xxxxxxx@localhost’ (Using password: YES)

the use in question exists, and Lasso (http://omnipilot.com) can get
to the databases just fine, as can i in cocoamysql – so i know the
user/password combo works. it has for a long, long time.

so, i’ve tried the fixconfig and such…

here’s an example output:

Attempting local installation of ‘mysql’
Local gem file not found: mysql*.gem
Attempting remote installation of ‘mysql’
Updating Gem source index for: http://gems.rubyforge.org
Building native extensions. This could take a while…
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
mysql-2.7 for inspection.
ruby extconf.rb install mysql\nchecking for mysql_query() in -
lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no

Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

am i missing something?

 - chris corwin
   http://flickerbulb.com

#2

hi chris

I am stuck on the exact same line of code in the book… i swear there
is a misprint or something! page 57 right?

anyway, i got past that error by including a specific username and
password (your login name and password) in my config/database.yml for
the development and test databases … it says in the book that you
may have to do this with some combos of OSX/MySQL/Rails have you done
that?

anyhoo i now get an error upon reaching the same line in the output
( identical test/fixtures/products.yml ) which reads …

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each

plus a whole load of other code if I add -t to the command (full
output in my thread “newbie generate scaffold”)

let me know if the database.yml file solves your initial problem…
and if you get the same second error as me.

3Quid
email - removed_email_address@domain.invalid

msn - removed_email_address@domain.invalid
aim - removed_email_address@domain.invalid


#3

This will help with your mysql binding problem in OSX:

http://habtm.com/articles/2005/08/04/installing-ruby-mysql-bindings-2-6-on-tiger-troubleshooting

You might also check to make sure you’re using the new mysql password
hash that appeared in v4.1. If you’re still using the old hash I don’t
believe Rails 1.0 or newer will connect.

jeff


#4

On Apr 4, 2006, at 3:44 PM, Jeff Everett wrote:

You might also check to make sure you’re using the new mysql password
hash that appeared in v4.1. If you’re still using the old hash I don’t
believe Rails 1.0 or newer will connect.

awwwwww, that’s so gotta be it — i am just stepping out, i’ll lazy
web this:

how do i do that?

but i am using mysql 4, not 4.1…

?

 - chris corwin
   http://flickerbulb.com

#5

On Apr 4, 2006, at 8:40 PM, Chris C. wrote:

how do i do that?

but i am using mysql 4, not 4.1…

a quick upgrade to MySQL 5.0 and i now get this:

b00ty:/Library/WebServer/Documents/Rails/depot chris$ ruby script/
generate scaffold Product Admin
exists app/controllers/
exists app/helpers/
exists app/views/admin
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/product.rb
identical test/unit/product_test.rb
identical test/fixtures/products.yml
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
b00ty:/Library/WebServer/Documents/Rails/depot chris$

any ideas would be soooo appreciated.

 - chris corwin
   317 418 1795
   http://flickerbulb.com

#6

On 4/4/06, Chris C. removed_email_address@domain.invalid wrote:

awwwwww, that’s so gotta be it — i am just stepping out, i’ll
lazy web this:

how do i do that?

but i am using mysql 4, not 4.1…

I’ll lazy answer :wink:
Google for

rails mysqladmin password

Chris M.
Web D.
Open Source & Web Standards Advocate
http://www.chriscodes.com/


#7

On Apr 7, 2006, at 6:27 PM, Chris M. wrote:

believe Rails 1.0 or newer will connect.
Google for

rails mysqladmin password

heh – yah, i got there, eventually.

that’s not it though, sorta.

well, we’ll see.

i ended up going to mysql 5, cause, why not?

now i get this:

b00ty:/Library/WebServer/Documents/Rails/depot chris$ ruby script/
generate scaffold Product Admin -t
exists app/controllers/
exists app/helpers/
exists app/views/admin
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/product.rb
identical test/unit/product_test.rb
identical test/fixtures/products.yml
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/
connection_adapters/mysql_adapter.rb:293:in columns' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/ base.rb:696:incolumns’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/
base.rb:1963:in attributes_from_column_definition' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/ base.rb:1347:ininitialize_without_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/
callbacks.rb:236:in initialize' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ generators/components/scaffold/scaffold_generator.rb:182:innew’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
generators/components/scaffold/scaffold_generator.rb:182:in
model_instance' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ generators/components/scaffold/scaffold_generator.rb:164:increate_sandbox’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
generators/components/scaffold/scaffold_generator.rb:85:in manifest' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ generators/components/scaffold/scaffold_generator.rb:85:incall’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
commands.rb:106:in render_template_part' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ commands.rb:284:incomplex_template’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
manifest.rb:47:in send' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ manifest.rb:47:insend_actions’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
manifest.rb:46:in each' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ manifest.rb:46:insend_actions’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
manifest.rb:31:in replay' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/ commands.rb:41:ininvoke!’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/rails_generator/
scripts/…/scripts.rb:31:in run' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/generate.rb:6 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire__’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/ dependencies.rb:136:inrequire’
script/generate:3
b00ty:/Library/WebServer/Documents/Rails/depot chris$

whiskey. tango. foxtrot.

 - chris corwin
   http://flickerbulb.com