small medium large xlarge

15 May 2008, 14:42
James Hogue (5 posts)

I just picked up a copy of the rails 2.0 (hammock?) book and I was playing with the Depot application using mysql. I did the following.

mysqladmin -u root create depot_development cd depot (I edited config/database.yml and commented out the line that says “encoding: utf8” ruby script/generate scaffold product title:string description:text image_url:string rake db:migrate

and I got the following error:

(in /home/jhogue/rails/book/depot3) == 1 CreateProducts: migrating ================================================ – create_table(:products) rake aborted! Mysql::Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ENGINE=InnoDB’ at line 1: CREATE TABLE products (id int(11) DEFAULT NULL auto_increment PRIMARY KEY, title varchar(255) DEFAULT NULL, description text DEFAULT NULL, image_url varchar(255) DEFAULT NULL, created_at datetime DEFAULT NULL, updated_at datetime DEFAULT NULL) ENGINE=InnoDB

What am I missing here? It seems that mysql is not configured for InnoDB and rails is using that?

15 May 2008, 15:18
Sam Ruby (633 posts)

It appears that you may have an old version of mysql installed. More details “here”:

In addition to the solutions mentioned on that web page, specifying :options => “TYPE=InnoDB” on your migration may help. See page 272 of the B1.1 version of the book for more details.

But I would recommend if you wish to proceed with MySQL that you consider upgrading it. You can determine which version of MySQL you are running with the following command:

mysql -h hostname -V

Look for the “Distrib” value. You probably want to see 5.x here, and 4.x may work, but 3.x is likely to cause you problems.

16 May 2008, 14:23
James Hogue (5 posts)


I upgraded mysql from 4.0 to 5.0 and it worked, but I had to edit /etc/my.cnf to add the INNODB stuff, so I am wondering if maybe that would have done it for 4.0 as well. I would check for you, but I nuked 4.0 completely before installing 5.0, so going back is not really an option. Someone else may want to check this out.

Thanks for your help!

You must be logged in to comment