【发布时间】:2014-04-10 16:49:06
【问题描述】:
这是我的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:migrate 对我来说很好。老实说,我很难过。
【问题讨论】:
-
我不确定
url是否包含连接所需的所有信息。您可能必须单独分解参数。见:example -
我居然把所有的url信息都爆出来了,把你添加的链接里的信息都包含进去了,还是不行。
-
没关系...我忘记触摸 tmp/restart.txt 来重新启动乘客...这有效。希望我能找到一种方法将信息放入环境变量中,就像默认设置一样。
-
啊,这是个老生常谈的问题。在开发模式下,Rails 将始终适应
app/或config/routes.rb中任何内容的更改,但其他任何内容都需要restart.txt技巧。
标签: ruby-on-rails ruby ruby-on-rails-4 passenger