After the PostgreSQL database is installed, only local access connections are accepted by default. If you want to access the PostgreSQL database server on another host, you need to configure it accordingly.
To configure a remote connection to a PostgreSQL database, you only need to modify pg_hba.conf and postgresql. conf under the data Directory.
Pg_cmd.conf: Configure database access permissions,
Postgresql. conf: configure the corresponding parameters of the PostgreSQL database server.
The following describes the configuration steps:
1. Modify the pg_cmd.conf file and configure the user's access permissions (# The line starting with the comment content ):
- # Type database user CIDR-ADDRESS METHOD
- # "Local" is for Unix domain socket connections only
- Local all trust
- # IPv4 local connections:
- Host all 127.0.0.1/32 trust
- Host all 192.168.1.0/24 md5
- # IPv6 local connections:
- Host all: 1/128 trust
The first entry is newly added. It indicates that all hosts on the network segment 192.168.1.0 are allowed to access the database using all valid database usernames and provide encrypted password verification.
Here, the number 24 is a subnet mask, which allows access to computers from 192.168.1.0 -- 192.168.1.255!
2. Modify the postgresql. conf file to change the listening mode of the database server to listening for connection requests from all hosts.
Go to # listen_addresses = 'localhost '. After PostgreSQL is installed, it only accepts the local localhost connection by default.
Remove the beginning of the line # and change the line content to listen_addresses = '*' to allow the database server to listen for connection requests from any host.
PostgreSQL deletes duplicate data rows in a table
Establishment of PostgreSQL database connection pool PgBouncer
Compiling PostgreSQL on Windows
Notes on PostgreSQL backup
PostgreSQL details: click here
PostgreSQL: click here