Question

So this is my database.yml:

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root

development:
  <<: *default
  database: test

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: vollapp_test

# Avoid production credentials in the repository,
# instead read the configuration from the environment.
#
# Example:
#   mysql2://myuser:mypass@localhost/somedatabase
#
production:
  adapter: mysql2
  url: <%= ENV["DATABASE_URL"] %>

On my production server, hosted by hostmonster i am getting a 500 error and the production log says Mysql2::Error (Access denied for user 'root'@'localhost'). The weird thing about this is my DATABASE_URL doesnt even use 'root' as the user. I know this is in fact may be a duplicate but I have tried all the answers from all the other questions I found on this and none of them fit / work for me. rake db:migrate works fine for me. Honestly im stumped.

Was it helpful?

Solution

You may need to spell out the configuration parameters in full in addition to the URL method:

production:
  adapter: mysql2
  username: username
  password: password
  host: hostname
  database: databasename
  url: <%+ ENV["DATABASE_URL"] %>

I hope they actually parse the url value in future versions of Rails because this seems to be a bit of duplicated effort.

Any changes to config/database.yml will require restarting your Rails process(es).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top