# Mysql::Error #28000Access denied

**URL:** <https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488>\
**Category:** Rails\
**Created:** [March 12, 2007, 12:20am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488 "2007-03-12T00:20:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Riot](https://www.ruby-forum.com/u/Riot)\
**Post date:** [March 12, 2007, 12:20am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488/1 "2007-03-12T00:20:04Z")

</div>

I’m on MAC OSX and I set up my environment as described here:

> **[Dan Benjamin](https://danbenjamin.com)**
>
> Dan Benjamin's personal website.

This may be too old and I just realized that, but before I attempt  
Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X:

> **[Dan Benjamin](https://danbenjamin.com)**
>
> Dan Benjamin's personal website.

Okay, I purchased a book “Rails Solutions: Ruby on Rails Made Easy” and  
I’m following along w/ the tutorial.

I do not understand this thing at all… I’m 100% sure I’m doing  
everything right, except I still get this error. Perhaps I need to  
update my setup?

Here’s what I do:

1. rails railslist

2. cd railslist

3. ruby script/server

4. Setup my Databases in Cocoa MySQL (localhost, root, password)

5. Update database.yml file w/ password (localhost and root are already  
set by default)

6. ruby script/generate model Classified

7. Update 001\_create\_classifieds.rb migration file w/

`class CreateClassifieds < ActiveRecord::Migration
def self.up
create_table :classifieds do |t|
t.column :title, :string
t.column :price, :float
t.column :location, :string
t.column :description, :text
t.column :email, :string
t.column :created_at, :timestamp
t.column :updated_at, :timestamp
end
end`

`
`

`def self.down
drop_table :classifieds
end
end`

1. rake migrate – check to see tables have been made in Cocoa  
(success!)

2. ruby script/generate controller Classified

3. Update classified\_controller.rb file w/

````plaintext
  def list
    @classifieds = Classified.find(:all)
  end

  def show
    @classified = Classified.find(params[:id])
  end

  def new
  end

  def create
  end

  def edit
  end

  def update
  end

  def delete
  end

end```

11. Point page to <a
href="http://localhost:3000/classified/list">http://localhost:3000/classified/list</a>

12. ERROR #28000Access denied for user 'root'@'localhost' (using
password: NO)

I don't get it, if rake can setup the tables then the rails must be
communicating fine w/ MySQL ??
````

---

<div class="post-metadata">

**Author:** ![Riot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Riot](https://www.ruby-forum.com/u/Riot)\
**Post date:** [March 12, 2007, 1:05am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488/2 "2007-03-12T01:05:15Z")

</div>

Riot wrote:

> 1. ruby script/server  
> `class CreateClassifieds < ActiveRecord::Migration
> end`
> 
> end  
> password: NO)
> 
> I don’t get it, if rake can setup the tables then the rails must be  
> communicating fine w/ MySQL ??

Shutdown the server. Check your database.yml file and make sure all the  
environments have a password set and try it again. The “(using password:  
NO)”  
implies it’s using the default database.yml setup where root has no  
password  
rather than the one you configured. rake runs independent of the having  
a  
server running which is why it picked up the database.yml changes.

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![Riot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Riot](https://www.ruby-forum.com/u/Riot)\
**Post date:** [March 12, 2007, 12:47am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488/3 "2007-03-12T00:47:12Z")

</div>

On 11-Mar-07, at 7:20 PM, Riot wrote:

> I’m on MAC OSX and I set up my environment as described here:

> 1. Update classified\_controller.rb file w/

> I don’t get it, if rake can setup the tables then the rails must be  
> communicating fine w/ MySQL ??
> 
> –

Get Riot.

I think the mysql error is a red herring - as you said the migration  
worked ok.

Do you have a model for Classified?

class Classified \< ActiveRecord::Base  
end

as well the controller is generally pluralized  
(classifieds\_controller.rb), although this isn’t likely causing this  
problem.

If the above don’t help, check log/development.log - it will likely  
have more symptoms.

cheers,  
Jodi

---

<div class="post-metadata">

**Author:** ![Riot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Riot](https://www.ruby-forum.com/u/Riot)\
**Post date:** [March 12, 2007, 2:07am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488/4 "2007-03-12T02:07:44Z")

</div>

> Do you have a model for Classified?
> 
> cheers,  
> Jodi

I forgot to list that step! But yes, I did create the model after  
setting up my databasbe.yml file

Thanks for the responses, Michael, I will try what you suggested.

---

<div class="post-metadata">

**Author:** ![Riot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Riot](https://www.ruby-forum.com/u/Riot)\
**Post date:** [March 12, 2007, 3:40am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488/5 "2007-03-12T03:40:37Z")

</div>

Michael W. wrote:

> Shutdown the server. Check your database.yml file and make sure all the  
> environments have a password set and try it again. The “(using password:  
> NO)”  
> implies it’s using the default database.yml setup where root has no  
> password  
> rather than the one you configured. rake runs independent of the having  
> a  
> server running which is why it picked up the database.yml changes.
> 
> –  
> Michael W.

Michael,

I did as you said and I get past that error now! I failed to mention  
earlier in the day that I had gotten it to work before, but I started  
getting this problem after I set a password to my ‘root’ user – how can  
I fix this from now on?

Should I update my setup?

---

<div class="post-metadata">

**Author:** ![Riot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Riot](https://www.ruby-forum.com/u/Riot)\
**Post date:** [March 12, 2007, 4:38am UTC](https://www.ruby-forum.com/t/mysql-error-28000access-denied/88488/6 "2007-03-12T04:38:31Z")

</div>

Riot wrote:

> I did as you said and I get past that error now! I failed to mention  
> earlier in the day that I had gotten it to work before, but I started  
> getting this problem after I set a password to my ‘root’ user – how can  
> I fix this from now on?
> 
> Should I update my setup?

It should be fixed now. There are a few changes you make to your app  
while the  
server is running in development mode that aren’t picked up until you  
restart  
the server. E.g. if you change config/environment.rb you need to restart  
the  
server for the changes to be seen.

–  
Michael W.
