postgresql 在 pgadmin 中创建新的本地服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53267642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:44:21  来源:igfitidea点击:

Create new local server in pgadmin?

postgresqlpgadmin

提问by Theo F

I have PostgreSQL 11 and PGadmin 4 installed on windows. Currently I'm connected to a AWS server which hosts all of my data.

我在 Windows 上安装了 PostgreSQL 11 和 PGadmin 4。目前,我已连接到托管我所有数据的 AWS 服务器。

I want to create a local server (localhost) as a testing environment where I can experiment. I can't seem to do it though, and the other similar questions on stack don't help. Here's what my process is:

我想创建一个本地服务器 (localhost) 作为我可以进行实验的测试环境。不过,我似乎无法做到,堆栈上的其他类似问题也无济于事。这是我的过程:

  1. in pgAdmin, right click 'Servers' and go Create>Server

  2. On the 'Create - Server' pop up box, i type in Name: Localserver. For 'connection' I type localhost. Port I leave as default '5432', db: postgres, username: postgres password: empty

  3. click save.

  1. 在 pgAdmin 中,右键单击“服务器”并转到“创建”>“服务器”

  2. 在“创建 - 服务器”弹出框中,我输入名称:Localserver。对于“连接”,我输入 localhost。端口我保持默认'5432',db:postgres,用户名:postgres 密码:空

  3. 点击保存。

however, I get an error:

但是,我收到一个错误:

Unable to connect to server:

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

无法连接到服务器:

无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“localhost”(::1) 上运行并接受端口 5432 上的 TCP/IP 连接?

无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“localhost”(127.0.0.1) 上运行并接受端口 5432 上的 TCP/IP 连接?

screenshot of error message

错误信息截图

What should I do? I am the admin if that makes a difference.

我该怎么办?如果这有所作为,我是管理员。

回答by Chris Curvey

This is probably one of two things.

这可能是两件事之一。

  1. You have set up a Postgres server, but have not adjusted listen_addressesin your postgresql.conf file, or

  2. You have not set up a Postgres server on your local machine. ("Create Server" is a bit misleading, it should probably be "Create Server Connection".)

  1. 您已经设置了 Postgres 服务器,但尚未listen_addresses在您的 postgresql.conf 文件中进行调整,或者

  2. 您尚未在本地计算机上设置 Postgres 服务器。(“创建服务器”有点误导,它可能应该是“创建服务器连接”。)

回答by richyen

Usually a “connection refused” error indicates that the database server is either 1) not running, or 2) configured in such a way that it is not listening to the right port or IP address. Be sure to check ps -efto see if Postgres is running, and also look at postgresql.confto see if portand listen_addressesare set properly.

通常,“连接被拒绝”错误表示数据库服务器 1) 未运行,或 2) 配置为未侦听正确的端口或 IP 地址。请务必检查ps -efPostgres 是否正在运行,并postgresql.conf查看是否正确设置了portlisten_addresses