use*_*031 6 postgresql ruby-on-rails
奇怪的错误.所有帮助赞赏.
这是我的database.yml
development:
adapter: postgresql
encoding: unicode
database: app_development
pool: 5
username: username
password:
test:
adapter: postgresql
encoding: unicode
database: app_test
pool: 5
username: username
password:
production:
adapter: postgresql
encoding: unicode
database: app_production
pool: 5
username: username
password:
Run Code Online (Sandbox Code Playgroud)
当我手动创建数据库并尝试使用它们时,例如rake db:test:preare我收到以下错误:
FATAL: database "postgres" does not exist
Run Code Online (Sandbox Code Playgroud)
当我尝试删除数据库时,我收到以下错误:
Couldn't drop app_development : #<PG::Error: FATAL: database "postgres" does not exist
>
Couldn't drop app_test : #<PG::Error: FATAL: database "postgres" does not exist
>
Couldn't drop app_production : #<PG::Error: FATAL: database "postgres" does not exist
Run Code Online (Sandbox Code Playgroud)
如果我尝试创建数据库,rake db:create:all我会收到以下错误:
app_development already exists
app_test already exists
app_production already exists
Run Code Online (Sandbox Code Playgroud)
所以看来我的database.yml没问题.但出于某种原因,它正在寻找一个名为postgres的数据库,当时这不是我的database.yml中的内容.
任何帮助赞赏.
编辑:
这里有更多来自rake的痕迹:
无法为{"adapter"=>"postgresql","encoding"=>"unicode","database"=>"app_production","pool"=> 5,"username"=>"username"创建数据库, "密码"=>无}
[Mac OS X] 我在使用 Linux 时从未遇到过 PostGreSQL 问题。但是,我开始使用 MacBook 并遇到与您相同的错误。所以... 可能这不是您期望的解决方案,但是这个应用程序解决了我所有的头疼问题。我只是想和大家分享一下。
你没有说你是否真的有一个 postgres 数据库,这就是错误所抱怨的。
大概不是,这个“rake”工具正在以用户 postgres 的身份连接到数据库 postgres,以便它可以创建新的数据库。显然,它需要像某人一样进行连接才能做任何事情。
请花时间浏览 PostgreSQL 手册并了解如何启用/控制日志记录。从长远来看,它会对你有好处。我猜 rake/rails 也有一个调试/日志设置。
| 归档时间: |
|
| 查看次数: |
11474 次 |
| 最近记录: |