【发布时间】:2014-02-19 03:07:01
【问题描述】:
我正在尝试创建一个使用 postgres 作为其数据库的 Ruby on Rails Web 应用程序。我无法使用 postgres 连接到服务器
我已经安装了 PostgreSQL 并成功创建了一个使用 postgres 的 Rails 应用程序。但是,当我运行“rails server”时,它会返回..
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on XXX:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `initialize': could not connect to server: Connection refused (PG::ConnectionBad)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
我认为我遇到了身份验证问题。我尝试关注两个 SO 链接,这些链接似乎对很多人都有效,但对我来说第一步都失败了。
How to configure postgresql for the first time?
此链接的第一步(su root)导致:“su: Authentication Failure”。
我正在尝试使用本指南: https://www.digitalocean.com/community/articles/how-to-install-and-use-postgresql-on-ubuntu-12-04
如果我使用“sudo -i”,“su - postgres”命令会起作用。 “createuser”然后结果:
Enter name of role to add: XXX(root username)
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
createuser: could not connect to database postgres: 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"?
在尝试遵循https://help.ubuntu.com/community/PostgreSQL 的 Ubuntu Postgres 指南时,我没有成功,与
sudo -u postgres psql postgres
返回:
psql: 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"?
谢谢!我还是一个初学者,所以请尽可能简单和详细地解释。
【问题讨论】:
-
请将
pg_lsclusters的结果添加到您的问题中。这将告诉您是否安装了 postgres 实例以及它们是否在线。
标签: ruby-on-rails postgresql ubuntu