09-08-2023, 01:32 PM
Configure your PostgreSQL server to allow other systems to access the database remotely. To do this, let the server listen to all IP addresses by modifying the configuration file.
Before continuing, use the exit command to exit the PostgreSQL prompt and return as a normal system user. Then follow these steps:
- Open the configuration file using a text editor. Replace vim if you are using another editor and change the directory accordingly:
- Look for the line listen_addresses.
- Remove the # symbol and change the value to an asterisk. This is what it should look like:
- Utilisez la commande :wq pour enregistrer les modifications et quitter vim.
- Définissez la politique d'accès pour authentifier la connexion des clients à votre serveur PostgreSQL. Pour ce faire, ouvrez le fichier pg_hba.conf dans le même répertoire à l'aide de vim. La commande devrait ressembler à ceci :
- Ajoutez une nouvelle règle en bas du fichier en utilisant cette syntaxe :
- For example, we will allow all TCP/IP connections from all users to all PostgreSQL databases. These users can use any IP address with an MD5 encrypted password. The rule looks like this:
- Restart the PostgreSQL service to apply the changes.
vim /etc/postgresql/14/main/postgresql.conf
listen_addresses = '*'
vim /etc/postgresql/14/main/pg_hba.conf
connexion base_de_données utilisateur adresse_ip cryptage
host all all 0.0.0.0/0 md5

