无法使用pgAdmin将PostgreSQL连接到远程数据库 [英] Unable to connect PostgreSQL to remote database using pgAdmin

查看:621
本文介绍了无法使用pgAdmin将PostgreSQL连接到远程数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IP为192.168.1.10的本地服务器(Ubuntu)上安装了PostgreSQL.现在,我正在尝试使用pgAdmin从IP为192.168.1.11的客户端计算机(Ubuntu)访问数据库.

I installed PostgreSQL on my local server (Ubuntu) with IP 192.168.1.10. Now, I'm trying to access the database from my client machine (Ubuntu) with IP 192.168.1.11 with pgAdmin.

我知道我必须在postgresql.conf和pg_hba.conf中进行更改以允许客户端连接.你能指导我吗?

I know I have to make changes in postgresql.conf and pg_hba.conf to allow the client to connect. Could you please guide me?

推荐答案

通过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.

这篇关于无法使用pgAdmin将PostgreSQL连接到远程数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆