Mysql::Error #28000Access denied

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

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:

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/

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

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.

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

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.

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?

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.