# Error accessing db through model - Rails 2.2.2, MySql 5.1.30

**URL:** <https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378>\
**Category:** Rails\
**Created:** [February 26, 2009, 12:42am UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378 "2009-02-26T00:42:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sktib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sktib](https://www.ruby-forum.com/u/sktib)\
**Post date:** [February 26, 2009, 12:42am UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378/1 "2009-02-26T00:42:09Z")

</div>

Folks,

I just installed Rails 2.2.2 on my box and MySql 5.1.30. Running a  
simple .find(:all) gives me a bunch of errors - snippet below.  
The only answer I have found in searching around is to go back to an  
older version of MySql. Is there any way to fix this or do I really have  
to revert the MySql version?

> > Meal.find(:all)  
> > ArgumentError: NULL pointer given  
> > from (eval):3:in `each_hash' from (eval):3:in`all\_hashes’  
> > from  
> > C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record  
> > /connection\_adapters/mysql\_adapter.rb:564:in `select' from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record /connection_adapters/abstract/database_statements.rb:7:in`select\_all\_without\_qu  
> > ery\_cache’

Thanks for your help.

-S

---

<div class="post-metadata">

**Author:** ![sktib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sktib](https://www.ruby-forum.com/u/sktib)\
**Post date:** [February 26, 2009, 3:42am UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378/2 "2009-02-26T03:42:09Z")

</div>

Have you created the database and migrated?

---

<div class="post-metadata">

**Author:** ![sktib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sktib](https://www.ruby-forum.com/u/sktib)\
**Post date:** [February 26, 2009, 7:04am UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378/3 "2009-02-26T07:04:10Z")

</div>

Jeff Emminger wrote:

> Have you created the database and migrated?

Yes Jeff, I have been able to create a database and run db:migrate  
successfully. I can see the tables in db and can also run direct sql  
queries successfully.

Forgot to add to my initial post - I am on Win XP.

---

<div class="post-metadata">

**Author:** ![sktib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sktib](https://www.ruby-forum.com/u/sktib)\
**Post date:** [February 26, 2009, 3:39pm UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378/4 "2009-02-26T15:39:53Z")

</div>

Rick wrote:

> Is it possible that you need to re-install the mysql gem? I think you  
> said you upgraded MySQL but you didn’t say from what version. I know  
> the mysql gem includes a C component that hooks in to the MySQL  
> library, this might be the source of your problem.

Thanks Rick. I reinstalled the MySql gem before the initial post. That  
gem installation was causing errors with RDoc installation (as reported  
by others as well) so I installed it with “gem install mysql --no-ri  
–no-rdoc”.

When you google the error I am getting, it has been reported by other  
folks too so it seems like something related to how Rails 2.2.2 and  
MySql 5.1.30 interact. The only solution I have found others suggest is  
to install an older version of MySql 5.1.30. BTW - I didn’t have an  
older version installed. I am starting with MySql 5.1.30

---

<div class="post-metadata">

**Author:** ![sktib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sktib](https://www.ruby-forum.com/u/sktib)\
**Post date:** [February 26, 2009, 7:42am UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378/5 "2009-02-26T07:42:41Z")

</div>

Is it possible that you need to re-install the mysql gem? I think you  
said you upgraded MySQL but you didn’t say from what version. I know  
the mysql gem includes a C component that hooks in to the MySQL  
library, this might be the source of your problem.

---

<div class="post-metadata">

**Author:** ![sktib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@sktib](https://www.ruby-forum.com/u/sktib)\
**Post date:** [February 27, 2009, 12:29am UTC](https://www.ruby-forum.com/t/error-accessing-db-through-model-rails-2-2-2-mysql-5-1-30/161378/6 "2009-02-27T00:29:36Z")

</div>

Sj Tib wrote:

> Rick wrote:
> 
> > Is it possible that you need to re-install the mysql gem? I think you  
> > said you upgraded MySQL but you didn’t say from what version. I know  
> > the mysql gem includes a C component that hooks in to the MySQL  
> > library, this might be the source of your problem.
> 
> Thanks Rick. I reinstalled the MySql gem before the initial post. That  
> gem installation was causing errors with RDoc installation (as reported  
> by others as well) so I installed it with “gem install mysql --no-ri  
> –no-rdoc”.
> 
> When you google the error I am getting, it has been reported by other  
> folks too so it seems like something related to how Rails 2.2.2 and  
> MySql 5.1.30 interact. The only solution I have found others suggest is  
> to install an older version of MySql 5.1.30. BTW - I didn’t have an  
> older version installed. I am starting with MySql 5.1.30

I installed an older version of MySql (5.0.77) and it works like a  
charm. Not sure what is the issue with Rails 2.2.2 and MySql 5.1.30.
