Remote connection to PostgreSQL server on Linux

Source: Internet
Author: User
Implement remote connection to PostgreSQL server on Linux-Linux Enterprise Application-Linux server application information. The following is a detailed description. As we all know, ipvs 8.1 has released two versions of Linux and Windows respectively. Therefore, how to implement these two systems is also introduced in the topic of remote connection.

In fact, windows has fewer steps than linux.

1. implement remote connection to the PostgreSQL server on Linux.

There are two main steps:

<1> enable PostgreSQL on Linux to enable the unix tcpip socket ".

Edit the $ S/data/postgresql. conf file,

Change tcpip_socket = off TO tcpip_socket = on.

<2> set the remote access authentication mechanism.

Edit the $ POSTGRES/data/pg_hba.conf file,

This file contains a lot of information about how to use this file for configuration,

At the bottom is the place where we can enter things.

There is a line of comment:

# Type database user CIDR-ADDRESS METHOD

It indicates that each row has five fields,

They are: Connection type, available database name, user, DIDR address, and verification method.

Below, I will only introduce some common options for each field.

Field 1: TYPE.

You can select local or host.

The former can only allow local users to log on to the ipvs database; the latter can accept remote client login. So,

We should use "host ".

Field 2: DATWABSE.

Name of the database that can be used by the connection user. It can make a specific

Database name. You can also use "all" to allow users to access all databases.

Field 3: USER.

You can specify a specific user to connect to the ipvs database (also combined with the following address field ),

You can also use "all" to allow all users to connect to the database.

Field 4: DIDR-ADDRESS.

This may make you feel overwhelmed and do not know what it is.

In fact, it is another way to express the IP address and mask.

Ipvs uses this field to allow IP addresses or ip cidr blocks to connect to the server.

The format is IP Address/mask.

This mask and subnet mask are just represented by a positive number smaller than or equal to 32,

Indicates that the subnet mask is 1 in height,

For example, 255.255.255.0 is "24", indicating that the 24-bit height is 1.

192.168.0.1/32 is equivalent to IP address 192.168.0.1, subnet mask is 255.255.255.255 network segment,

Obviously, this only indicates the IP address 192.168.0.1.

If you are not familiar with the IP address and subnet mask, please refer to the relevant information.

Field 5: METHOD.

This is the verification method. Optional values:

Reject: Deny Access From users of this IP address;

Md5: the password is hashed by md5;

Password: the password is transmitted in plain text !);

Krb5: the password uses krb5 as the hash code.

The following example shows how to set the parameters:

# Type database user CIDR-ADDRESS METHOD

# Allow all users with IP address 192.168.0.1 to log on to all databases on ipvs server and use md5 verification.

Host all 192.168.0.1/32 md5

# Allow the user testuser to log on to the ipvs server on any machine in the network segment of 192.168.0.XX,

# Only the database testdb can be used and md5 verification is used.

Host testdb testuser 192.168.0.1/24 md5

2. remote connection to the PostgreSQL server on Windows.

After reading the preceding information, this configuration is very simple. Except for the steps described above <1> after modification is not required,

You only need to configure the items described in step <2>. (Because winodws does not have a unix tcpip socket ).
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.