0

I am using mySQL and Rails 3.2 and I run into this problem: The error code is: "rake aborted! Access denied for user 'root'@'localhost' (using password: NO)"

I am particularly sure that my database.yml is configured correctly, as follow:

development:
  adapter: mysql2
  encoding: utf8
  database: simple_cms_development
  pool: 5
  username: simple_cms
  password: my_actual_password
  socket: /tmp/mysql.sock

I am very confused as the error said access denied for user 'root'@'localhost'. Now I cannot run any command like rake, rake db:migrate.

I've gone through other similar questions on Stackoverflow like (Why my rake db:migrate throws error message?) but the answer does not solve my problem.

Community
  • 1
  • 1
phanatuan
  • 495
  • 1
  • 5
  • 14
  • Is the configuration block you are looking at the same one that is actually used when you run your task? Its clear it's for some reason trying to access the database as the root user, and it cannot. – Tanel Suurhans Feb 16 '14 at 17:33
  • How is your db configured? You need to take a look to your my.cnf – Ruby Racer Feb 16 '14 at 18:16
  • I enter mysql with the info as above (Username: simple_cms). Then I typed rake and it returns the error code as above. I have no idea why the error was refering to the user as 'root'@'localhost' but not as user 'simple_cms' as I indicated in my database.yml file – phanatuan Feb 16 '14 at 18:16
  • @StavrosSouvatzis: I have no such file as 'my.cnf' ... – phanatuan Feb 16 '14 at 18:17
  • Well, you do have mysql installed, so you should have my.cnf somewhere in your system... If you're on linux, probably on /etc/mysql... Oh, also, if you are running a rails server, make sure to restart it after having changed in any way your database.yml – Ruby Racer Feb 16 '14 at 18:18
  • Refer to this [Stack Overflow thread](http://stackoverflow.com/a/16003404/2300000) for a solution – Monideep Feb 16 '14 at 18:23
  • @StavrosSouvatzis: I'm using MAC OS 10.9. I run the command "locate my.cnf" but it is not found too .. – phanatuan Feb 16 '14 at 18:25
  • 1
    It might not be that, but in case this is what you need http://stackoverflow.com/questions/10757169/mysql-my-cnf-location – Ruby Racer Feb 16 '14 at 18:30
  • @deep: I also came across the thread you bring up, followed but no use. My command and the response from MySQL, followed from the instructions are: CREATE USER 'root'@'localhost' IDENTIFIED BY 'my_actual_password'; =>ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost' GRANT ALL privileges on simple_cms_development.* to 'root'@'localhost' identified by 'my_actual_password'; => Query OK, 0 rows affected (0.02 sec) FLUSH PRIVILEGES; => Query OK, 0 rows affected (0.03 sec) – phanatuan Feb 17 '14 at 11:50
  • @phanatuan error 1396 indicate that root user already exists. First try to login as root, create the database, create a user simple_cms with password, select the database, grant all privileges to the user simple_cms and this will solve permission problem for the user. – Monideep Feb 17 '14 at 13:54
  • I follow all the steps above for simple_cms but the problem still there... What I find most confused about is the error message, where it says "using password: NO" (rake aborted! Access denied for user 'root'@'localhost' (**using password: NO**)). I do have a password for every users, including root ... – phanatuan Feb 18 '14 at 04:23

0 Answers0