# Problem with setting up database.

**URL:** <https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217>\
**Category:** rubyonrails-talk\
**Created:** [December 22, 2006, 1:51pm UTC](https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217 "2006-12-22T13:51:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mandava](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Mandava](https://discuss.rubyonrails.org/u/Mandava)\
**Post date:** [December 22, 2006, 1:51pm UTC](https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217/1 "2006-12-22T13:51:29Z")

</div>

Hey,

I’m new to Rails and Ruby. I’m using the book “Agile Web Development 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?

---

<div class="post-metadata">

**Author:** ![toby\_privett](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@toby\_privett](https://discuss.rubyonrails.org/u/toby_privett)\
**Post date:** [December 22, 2006, 2:08pm UTC](https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217/2 "2006-12-22T14:08:20Z")

</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:** ![Justin\_Blake](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@Justin\_Blake](https://discuss.rubyonrails.org/u/Justin_Blake)\
**Post date:** [December 23, 2006, 4:50pm UTC](https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217/3 "2006-12-23T16:50:37Z")

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

---

<div class="post-metadata">

**Author:** ![Bill\_Walton](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@Bill\_Walton](https://discuss.rubyonrails.org/u/Bill_Walton)\
**Post date:** [December 23, 2006, 10:15pm UTC](https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217/4 "2006-12-23T22:15:13Z")

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

---

<div class="post-metadata">

**Author:** ![toby\_privett](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@toby\_privett](https://discuss.rubyonrails.org/u/toby_privett)\
**Post date:** [December 26, 2006, 10:49pm UTC](https://discuss.rubyonrails.org/t/problem-with-setting-up-database/6217/5 "2006-12-26T22:49:34Z")

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