JJD*_*JJD 6 postgresql ruby-on-rails ruby-on-rails-3 rails-postgresql postgresql-9.1
我正在尝试创建一个使用PostgreSQL的Rails应用程序.这是对我所做的描述.
PostgreSQL设置:
我通过由Martin Pitt维护的ppa:pitti/postgresql安装了PostgreSQL 9.1.3 .之前安装了PostgreSQL 8.4; 我不确定它是否仍然安装或消失.
sudo service postgresql start.我在pg_hba.conf中的 postgres配置如下(为了便于阅读,删除了注释).
[...]
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Run Code Online (Sandbox Code Playgroud)
Rails设置:
现在我想创建一个使用PostgreSQL的Rails应用程序.
rails new my_test_app -d postgresql.user名称,并password在config/database.yml中进行开发和测试,并删除了生产.host: localhost和port: 5433在配置/ database.yml中.这是我的config/database.yml的内容(为了便于阅读,删除了注释).
development:
adapter: postgresql
encoding: unicode
database: my_test_app_development
pool: 5
username: johndoe
password: password
host: localhost
port: 5433
test:
adapter: postgresql
encoding: unicode
database: my_test_app_test
pool: 5
username: johndoe
password: password
Run Code Online (Sandbox Code Playgroud)
问题:
但是,当我运行时,bundle exec rake db:create:all我收到以下错误消息.
could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"?
[...]
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode",
"database"=>"my_test_app_test", "pool"=>5, "username"=>"johndoe",
"password"=>"password"}
Run Code Online (Sandbox Code Playgroud)
问题:
为什么端口与我通过pgadmin3成功连接时使用的端口不同?
JJD*_*JJD 18
@Riateche:最后,我看到测试环境的数据库配置错过了主机和端口的显式设置.将设置添加到测试环境后,我能够bundle exec rake db:create:all成功运行该命令.
我必须说,我不喜欢他们建议开发环境的那些设置,但没有为其他环境添加它们.正如我所证明的那样,这很可能会错过它们.
test:
adapter: postgresql
encoding: unicode
database: my_test_app_test
pool: 5
username: johndoe
password: password
host: localhost
port: 5433
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29090 次 |
| 最近记录: |