简体   繁体   English

使用pgAdmin连接到Rails应用程序Postgres DB

[英]Connecting to Rails app Postgres DB using pgAdmin

I'm having trouble connecting to the database for my Rails app using pgAdmin. 我无法使用pgAdmin连接到我的Rails应用程序的数据库。 I have the server running and I believe that my server properties are correct in pgAdmin. 我正在运行服务器,并且我相信我的服务器属性在pgAdmin中是正确的。 Here's what I have in pgAdmin server properties: 这是pgAdmin服务器属性中的内容:

Name: achievenext_dev
Host: localhost
port: 3000
SSL:
Maintenance DB: postgres
username: achievenext
password: ******
Store password: true
Restore env?: true
DB Restriction: 
Service:
Connect now: true

And in my database.yml file: 在我的database.yml文件中:

development:
  adapter: postgresql
  host: localhost
  username: achievenext
  password: ******
  database: achievenext_dev

But when I try to connect pgAdmin returns this error: 但是当我尝试连接pgAdmin时返回此错误:

An error has occurred: 发生了错误:

Error connecting to the server: server closed the connection unexpectedly. 连接服务器时出错:服务器意外关闭了连接。 This probably means the server terminated abnormally before or while processing the request. 这可能意味着服务器在处理请求之前或期间异常终止。

But there are no errors on my server. 但是我的服务器上没有错误。 It appears to be running fine. 它似乎运行良好。 Can't figure out what I'm doing wrong here. 无法弄清楚我在做什么错。

Try adding a port to your development.yml file. 尝试将端口添加到您的development.yml文件。 Especially if you run a windows OS. 特别是如果您运行Windows OS。

The default port is port:5432 and I'm not sure if specifying the port:3000 in your pgAdminIII would cause problems. 默认端口是port:5432 ,我不确定在pgAdminIII中指定port:3000是否会引起问题。

Can you try to use 127.0.0.1 instead of localhost? 您可以尝试使用127.0.0.1代替localhost吗? I know mysql often causes problems that it will try to connect to the socket file instead of making a TCP connection. 我知道mysql经常会引起问题,它将尝试连接到套接字文件而不是建立TCP连接。

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

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