dimanche 5 juin 2016

Ruby Rails: Access denied for user 'root'@'localhost' (using password: YES)

I have read other questions similar to this one. I feel that my situation is different enough to ask again for extra possible problem.

I have a Ruby on Rails app all setup. I have set up other before so I am somewhat familiar with doing rails. My specific problem with this error:
Access denied for user 'root'@'localhost' (using password: YES)

Here is my database.yml file

default: &default
  adapter: mysql2
  host: localhost
  username: cmsapp
  password: <%= ENV['CMSAPP_PASSWORD'] %>
  port: 3306
  pool: 5
  timeout: 5000

development:
  <<: *default
  #socket: /var/run/mysqld/mysqld.sock
  database: cms_dev
  socket: /var/run/mysqld/mysqld.sock 

production:
  <<: *default
  database: cms_prod

The problem I am having is it seem to me that the password is not getting parsed from the ENV['CMSAPP_PASSWORD'] environment variable. I have double/triple check the password on the mysql db.

Ruby errors on this line:

connect user, pass, host, port, database, socket, flags

in the console at bottom of the page, I type in pass to see whats in the variable, and I get "<%= ENV[CMSAPP_PASSWORD] %>". if I type just 'ENV[CMSAPP_PASSWORD]' I get the correct password. So I know the right password is there, but I believe its sending the literal "<%= ENV[CMSAPP_PASSWORD] %>". So even though the correct password is in the environment variable, I still get the error: Access denied for user 'root'@'localhost' (using password: YES)

If I put the password on the password: line, it does connect. So I do know that the password is correctly set in mysql. How do I troubleshoot weather the password is being properly extracted from the environment variable? Or how to figure out why it is not reading the environment variable?

Thanks for any help.

Aucun commentaire:

Enregistrer un commentaire