且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用pgAdmin将PostgreSQL连接到远程数据库

更新时间:2022-06-11 22:01:39

通过pgAdmin3远程连接到PostgreSQL服务器实际上是一个三步过程.

It is actually a 3 step process to connect to a PostgreSQL server remotely through pgAdmin3.

注意:我使用Ubuntu 11.04和PostgreSQL 8.4.

Note: I use Ubuntu 11.04 and PostgreSQL 8.4.

  1. 您必须使PostgreSQL侦听远程传入的TCP连接,因为默认设置仅允许侦听回送接口上的连接.为了能够远程访问服务器,您必须将以下行添加到文件/etc/postgresql/8.4/main/postgresql.conf:

listen_addresses ='*'

默认情况下,PostgreSQL拒绝从任何远程地址接收到的所有连接,您必须通过在/etc/postgresql/8.4/main/pg_hba.conf:

PostgreSQL by default refuses all connections it receives from any remote address, you have to relax these rules by adding this line to /etc/postgresql/8.4/main/pg_hba.conf:

托管所有0.0.0.0/0 md5

这是一个访问控制规则,如果任何人都可以提供有效的密码(md5关键字),则允许任何人从任何地址登录.您可以使用所需的网络/掩码而不是0.0.0.0/0.

This is an access control rule that let anybody login in from any address if he can provide a valid password (the md5 keyword). You can use needed network/mask instead of 0.0.0.0/0 .

在将这些修改应用于配置文件后,需要重新启动PostgreSQL服务器.现在可以使用用户名和密码远程登录服务器.

When you have applied these modifications to your configuration files you need to restart PostgreSQL server. Now it is possible to login to your server remotely, using the username and password.