# Problem with setting up database

**URL:** <https://www.ruby-forum.com/t/problem-with-setting-up-database/80227>\
**Category:** Rails\
**Created:** [December 22, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/problem-with-setting-up-database/80227 "2006-12-22T14:55:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prithvi\_Krishna\_Man](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@Prithvi\_Krishna\_Man](https://www.ruby-forum.com/u/Prithvi_Krishna_Man)\
**Post date:** [December 22, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/problem-with-setting-up-database/80227/1 "2006-12-22T14:55:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Prithvi\_Krishna\_Man](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@Prithvi\_Krishna\_Man](https://www.ruby-forum.com/u/Prithvi_Krishna_Man)\
**Post date:** [December 22, 2006, 3:09pm UTC](https://www.ruby-forum.com/t/problem-with-setting-up-database/80227/2 "2006-12-22T15:09:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Prithvi\_Krishna\_Man](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@Prithvi\_Krishna\_Man](https://www.ruby-forum.com/u/Prithvi_Krishna_Man)\
**Post date:** [December 23, 2006, 11:09pm UTC](https://www.ruby-forum.com/t/problem-with-setting-up-database/80227/3 "2006-12-23T23:09:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Prithvi\_Krishna\_Man](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@Prithvi\_Krishna\_Man](https://www.ruby-forum.com/u/Prithvi_Krishna_Man)\
**Post date:** [December 24, 2006, 1:06am UTC](https://www.ruby-forum.com/t/problem-with-setting-up-database/80227/4 "2006-12-24T01:06:23Z")

</div>

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” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “Ruby on Rails: Talk” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Saturday, December 23, 2006 10:50 AM  
Subject: [Rails] Re: Problem with setting up database.

---

<div class="post-metadata">

**Author:** ![Prithvi\_Krishna\_Man](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c6cbf5/32.png) [@Prithvi\_Krishna\_Man](https://www.ruby-forum.com/u/Prithvi_Krishna_Man)\
**Post date:** [December 26, 2006, 11:50pm UTC](https://www.ruby-forum.com/t/problem-with-setting-up-database/80227/5 "2006-12-26T23:50:48Z")

</div>

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