简体   繁体   English

rails上的ruby无法在本地连接到postgresql

[英]ruby on rails cannot connect to postgresql locally

I have been trying to set up my ruby on rails dev environment for a project I just started working on. 我一直在尝试在rails dev环境中为我刚刚开始工作的项目设置我的ruby。 I have installed Ruby 1.9.3, Rails 3.2, and postgresql 9.1.4 on Ubuntu 12, and when I try rake db:create:all I get the message: 我已经在Ubuntu 12上安装了Ruby 1.9.3,Rails 3.2和postgresql 9.1.4,当我尝试rake db:create:all我收到消息:

/var/lib/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in `initialize': could not connect to server: No such file or directory (NameError)
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I then added: 然后我补充说:

host: localhost 主持人:localhost

port: 5432 港口:5432

to my database.yml file, which let me do db:create:all and db:migrate, but when I run the rails server locally it still has the same error. 到我的database.yml文件,它让我做db:create:all和db:migrate,但是当我在本地运行rails服务器时它仍然有同样的错误。

I have checked that the postgresql server is running, which it is (I also know it is running since rake worked earlier), and have tried a fresh install of postgresql. 我已经检查过postgresql服务器正在运行,它是(我也知道它正在运行,因为rake之前工作),并尝试了全新安装的postgresql。 What might I be missing to make this work? 我可以缺少什么才能使这项工作?

Are you sure your postgres server is running? 你确定你的postgres服务器正在运行吗? If you do ps -aef|grep postgres , you should see something like this: 如果你做ps -aef|grep postgres ,你应该看到这样的东西:

[root@haddock ~]# ps -aef|grep 'postgres'
postgres  5963  5475  0 21:28 ?        00:00:00 /usr/postgresql/bin/postmaster -D <your postgres directory>
postgres  5972  5963  0 21:28 ?        00:00:00 postgres: writer process                          
postgres  5973  5963  0 21:28 ?        00:00:00 postgres: wal writer process                      
postgres  5974  5963  0 21:28 ?        00:00:00 postgres: autovacuum launcher process             
postgres  5975  5963  0 21:28 ?        00:00:00 postgres: stats collector process                 
admin     6750  6607  0 21:30 ttyS0    00:00:00 grep postgres

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM