# Newbie problem: ActiveRecord::StatementInvalid

**URL:** <https://www.ruby-forum.com/t/newbie-problem-activerecord-statementinvalid/127170>\
**Category:** Rails\
**Created:** [January 25, 2008, 7:08pm UTC](https://www.ruby-forum.com/t/newbie-problem-activerecord-statementinvalid/127170 "2008-01-25T19:08:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmezzetti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@danmezzetti](https://www.ruby-forum.com/u/danmezzetti)\
**Post date:** [January 25, 2008, 7:08pm UTC](https://www.ruby-forum.com/t/newbie-problem-activerecord-statementinvalid/127170/1 "2008-01-25T19:08:25Z")

</div>

Please,  
I am just beginning to learn RoR, following the “Up and running”  
tutorial.  
setup: ruby and ror=latest; mysql 4.0.17; WEBrick.

#Created the app I had to add the -d mysql after looking in the forums,  
latest RoR does not defaults to mysql

rails -d mysql \chapter1

(MySQL)  
create database chapter1\_development;  
grant all on _._ to ‘ODBC@localhost’;

ruby script/generate controller Greeting

At this point I should see at localhost:3000/greeting something like  
“an error message telling you that index is an unknown action.” (the  
tutorial says)  
Instead I see this:

ActiveRecord::StatementInvalid in GreetingController#index  
Mysql::Error: Unknown system variable ‘NAMES’: SET NAMES ‘utf8’

This is the response I get for EVERY request, even  
localhost:3000/rails/info/properties.

MySQL complains about an unknown system variable, NAMES. I searched the  
mysql docs, hoping this variable would be present in later versions of  
MySQL; so upgrading the database would solve the problem. But this  
variable is nonexistent, in any version of the database.

So what’s going on?

Thanks to all

---

<div class="post-metadata">

**Author:** ![danmezzetti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@danmezzetti](https://www.ruby-forum.com/u/danmezzetti)\
**Post date:** [January 25, 2008, 8:23pm UTC](https://www.ruby-forum.com/t/newbie-problem-activerecord-statementinvalid/127170/2 "2008-01-25T20:23:41Z")

</div>

does this help:

> **[\#1 Rated CRM Platform | CRM Software & Tools | SugarCRM](https://www.sugarcrm.com/)**
>
> Sugar helps business create customers for life with the world's most intelligent CRM platform. With SugarCRM, you let the platform do the work. Get a demo today!

a lot of people seem to have the same problem and a solution is  
suggested…

ps I just googled for: Mysql::Error: Unknown system variable ‘NAMES’:  
SET NAMES ‘utf8’ (not between speech marks and the above was top of the  
list baby yeah!

---

<div class="post-metadata">

**Author:** ![danmezzetti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@danmezzetti](https://www.ruby-forum.com/u/danmezzetti)\
**Post date:** [February 13, 2008, 6:16am UTC](https://www.ruby-forum.com/t/newbie-problem-activerecord-statementinvalid/127170/3 "2008-02-13T06:16:45Z")

</div>

I have explained the solution in details on my blog  
[http://rohitagarwal24.blogspot.com/](http://rohitagarwal24.blogspot.com/)  
Rohit

---

<div class="post-metadata">

**Author:** ![danmezzetti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@danmezzetti](https://www.ruby-forum.com/u/danmezzetti)\
**Post date:** [February 3, 2008, 5:24pm UTC](https://www.ruby-forum.com/t/newbie-problem-activerecord-statementinvalid/127170/4 "2008-02-03T17:24:36Z")

</div>

I also faced the same error. Mysql::Error: Unknown system variable  
‘NAMES’: SET NAMES ‘utf8’  
I found that in the config\database.yml file there is a line encoding:  
utf8  
I solved this error by removing the line encoding: utf8 from the file  
config\database.yml file. Do this for development, test, production  
settings.  
It worked for me.

-Rohit

On Jan 25, 11:08 pm, Daniele Mezzetti \<rails-mailing-l…@andreas-
