# Connecting to mysql on OS X 10.4

**URL:** <https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823>\
**Category:** Rails\
**Created:** [April 4, 2006, 4:52pm UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823 "2006-04-04T16:52:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 4, 2006, 4:52pm UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/1 "2006-04-04T16:52:29Z")

</div>

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](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](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

```

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 4, 2006, 6:31pm UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/2 "2006-04-04T18:31:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 4, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/3 "2006-04-04T21:48:07Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 5, 2006, 2:42am UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/4 "2006-04-05T02:42:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 5, 2006, 7:18am UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/5 "2006-04-05T07:18:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 8, 2006, 12:30am UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/6 "2006-04-08T00:30:22Z")

</div>

On 4/4/06, Chris C. [removed\_email\_address@domain.invalid](mailto: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 😉  
Google for

rails mysqladmin password

–

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

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 8, 2006, 12:33am UTC](https://www.ruby-forum.com/t/connecting-to-mysql-on-os-x-10-4/56823/7 "2006-04-08T00:33:24Z")

</div>

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:in`columns’  
/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:in`initialize\_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:in`new’  
/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:in`create\_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:in`call’  
/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:in`complex\_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:in`send\_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:in`send\_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:in`invoke!’  
/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:in`require\_\_’  
/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:in`require’  
script/generate:3  
b00ty:/Library/WebServer/Documents/Rails/depot chris$

whiskey. tango. foxtrot.

```
 - chris corwin
   http://flickerbulb.com
```
