这是我的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"] %>在我的生产服务器(由hostmonster托管)上,我得到了一个500个错误,生产日志上写着Mysql2::Error (Access denied for user 'root'@'localhost')。奇怪的是,我的DATABASE_URL甚至没有使用'root‘作为用户。我知道这可能是重复的,但我已经尝试了所有的答案,从所有其他问题,我发现,没有一个适合我/工作。rake db:迁移对我来说很好。老实说我很困惑。
发布于 2014-04-10 18:23:28
除了URL方法之外,您可能还需要详细说明配置参数:
production:
adapter: mysql2
username: username
password: password
host: hostname
database: databasename
url: <%+ ENV["DATABASE_URL"] %>我希望他们能够在未来版本的Rails中实际解析url值,因为这似乎有点重复。
对config/database.yml的任何更改都需要重新启动Rails进程(Es)。
https://stackoverflow.com/questions/22994184
复制相似问题