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 rails projects 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'] %> <-- this line is not working
port: 3306
pool: 5
timeout: 5000
development:
<<: *default
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 or pulled from the ENV['CMSAPP_PASSWORD'] environment variable. I have double/triple check the password on the mysql db. If I put the literal password on the password: line,(which I am not supposed to do) it does connect. So I do know that the password is correctly set in mysql.
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)
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?
Update 2016-06-09
I have switched back to the original mysql gem and all works as it is supposed to. I don't recommend anyone use the mysql2 gem. It DOES NOT have the database.yml file use environment variables. This is a security issue. I will not be using mysql2 gem until it can pull environment variables properly.
Thanks for any help.
Aucun commentaire:
Enregistrer un commentaire