MySql Error 1045 after I did rake db:create

You might try and access MySQL using the Terminal.app. At the command line run:

mysql -u root

if you expect the root password to be blank and yet see this:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

You know the password has been changed.

Sounds like the root password has been changed. If you do not know what it is, follow these instructions to reset the password:Resetting MySQL password.


This answer is in connection with Ruby on Rails framework where this behavior occurred

  1. have mysql with user root and password
  2. bootstrap new rails project using with mysql "rails new projectname
    -d mysql"
  3. do not modify config/database.yml - defaults credentials for server are name: root, password is blank
  4. rake db:create prompt show up - asking for root password and then when you provide root password

the answer is in GRANT command on line 68 in here

basically it executed GRANT command with credentials matches your current database.yml

I have discussed this topic and behavior will improved and it is taken and reported as a bug.