我们刚刚将虚拟机升级到了我认为相同的ruby配置(通过RVM ...... Ruby 1.9.2,Rails 3.0.7,DataMapper 1.1.0)。最大的区别是我们从MySQL 5.0到5.1。
出于某种原因,在我们的旧虚拟机上工作的完全相同的代码/ database.yml现在在尝试连接到数据库的时候失败了。
问题是这个YAML:
mysql_defaults: &mysql_defaults
adapter: mysql
encoding: UTF-8
username: user
password: pass
host: localhost
development:
<<: *mysql_defaults
database: devdb
production:
<<: *mysql_defaults
database: productiondb
host: master.db.site.com
只是扩展到:
"mysql_defaults" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
},
"development" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
},
"production" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
}
而不是:
"mysql_defaults" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost"
},
"development" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"localhost",
"database"=>"devdb"
},
"production" => {
"adapter"=>"mysql",
"encoding"=>"UTF-8",
"username"=>"user",
"password"=>"pass",
"host"=>"master.db.site.com",
"database"=>"productiondb"
}
以前有人经历过这个吗?
根据Gemfile.lock(我删除它并再次运行bundle install,只是为了理智),所有已安装的依赖项都是相同的(即Gemfile.lock在旧设置和新设置之间不区分)。 database.yml也没有。
答案 0 :(得分:18)
Psych是新的YAML解析器,可能更好,但不能合并散列键。
答案 1 :(得分:1)
由于您已完成升级,因此可能是您的数据库权限搞砸了。尝试查看您具有必要的权限,即代码所在的计算机具有在数据库计算机上连接和修改的权限。看着你的database.yml它应该像“
GRANT ALL PRIVILEGES ON productionbd.* to 'user'@'<app-server-ip>' identified by 'pass';