Problem with setting up database

Hey,

I’m new to Rails and Ruby.
I’m using the book “Agile Web D. with Rails, 1st Edition”.

As per the instructions, I created a file called create.sql in db folder
of
my app, following is the sql:

drop table if exists products;
create table products (
id int not null auto_increment,
title varchar(100) not null,
description text not null,
image_url varchar(200) not null,
price decimal(10,2) not null,
primary key (id)
);

And when i run the command

mysql depot_development <db/create.sql

i get an error msg

ERROR 1045 (28000) : Access denied for user ‘ODBC’@‘localhost’ (using

passowrd: NO)

and when i try to use the same sql in the mysql prompt directly, it
works!!
can anyone tell me why this is so?


Prithvi Krishna Mandava
(91)9880067859

ERROR 1045 (28000) : Access denied for user ‘ODBC’@‘localhost’ (using
passowrd: NO)

and when i try to use the same sql in the mysql prompt directly, it works!!
can anyone tell me why this is so?

It sounds like you are logged into mysql as a different user i.e. not
‘ODBC’.

What happens when you run the command as root:
sudo mysql depot_development <db/create.sql

Prithvi Krishna Mandava wrote:

ERROR 1045 (28000) : Access denied for user ‘ODBC’@‘localhost’ (using
passowrd: NO)

Double check your database.yml. Make sure the username and password are
the same ones you’re using on the command line (or the same as your
login account if you’re not using any on the command line).

Justin B.

In MySQL, enter:

grant all on database_name.* to ‘ODBC’@‘localhost’;

Haven’t figured out exactly what makes this necessary, but it fixes the
problem.

hth,
Bill

----- Original Message -----
From: “blaix” [email protected]
To: “Ruby on Rails: Talk” [email protected]
Sent: Saturday, December 23, 2006 10:50 AM
Subject: [Rails] Re: Problem with setting up database.

grant all on database_name.* to ‘ODBC’@‘localhost’;

Haven’t figured out exactly what makes this necessary, but it fixes the
problem.

It gives admin permission to the database for the user:
‘ODBC’@‘localhost’.
Without granting permission, the user doesn’t have access to the
database.

Fine for development, but not a good idea in production to grant
permissions
so freely.