feat: extend PostgreSQL doc

This commit is contained in:
dancingCycle 2024-02-21 14:00:20 +01:00
parent b8425909fc
commit b34cc5a651
3 changed files with 52 additions and 55 deletions

View File

@ -0,0 +1,7 @@
# Disable Start Up At System Boot
* If you install the PostgreSQL database from packages, it is automatically added to the start up scripts of the operating system. If you are only learning to work with the database, it is unnecessary to start the database each time you boot the system. Remove system startup link for the PostgreSQL database
```
sudo update-rc.d -f postgresql remove
```

View File

@ -0,0 +1,42 @@
# Allow Remote Connections
* configure ports and update firewall using the [firewall setup](firewall.md)
```
sudo ufw allow 5432
sudo ufw enable
sudo ufw status numbered
```
* create config backup
```
sudo cp /etc/postgresql/<version>/main/postgresql.conf /etc/postgresql/<version>/main/postgresql.conf-backup
```
* open config file to define what IP addresses postgres to listen on
```
sudo vi /etc/postgresql/<version>/main/postgresql.conf
```
* edit config file like this
```
#listen_addresses = 'localhost'
listen_addresses = '*'
```
* open config file to define access to all databases for all users with an encrypted key
```
sudo vi /etc/postgresql/<version>/main/pg_hba.conf
```
* edit config file like this
```
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
host all all :/0 md5
```
* restart PostgreSQL to enable the changes
```
sudo systemctl restart postgresql
systemctl status postgresql
```

View File

@ -6,7 +6,7 @@
NOTE: Insert the postgresql version <psql version> that is running on the respective host
```
cd /etc/postgresql/<psql version>/main/
sudo cp pg_hba.conf pg_hba.conf-backup
sudo cp pg_hba.conf pg_hba.conf-bckp
```
* switch authentication method from ```peer``` to ```md5``` for all local users connecting by Unix domain sockets by opening the following config file and adding the example configuration
@ -27,58 +27,6 @@ sudo systemctl restart postgresql
systemctl status postgresql
```
TODO: move the following description to dedicated setup files
* OPTION: allow remote connections like [this](./postgres-connect-remote.md)
# Allow Remote Connections
* configure ports and update firewall using the [firewall setup](firewall.md)
```
sudo ufw allow 5432
sudo ufw enable
sudo ufw status numbered
```
* create config backup
```
sudo cp /etc/postgresql/<version>/main/postgresql.conf /etc/postgresql/<version>/main/postgresql.conf-backup
```
* open config file to define what IP addresses postgres to listen on
```
sudo vi /etc/postgresql/<version>/main/postgresql.conf
```
* edit config file like this
```
#listen_addresses = 'localhost'
listen_addresses = '*'
```
* open config file to define access to all databases for all users with an encrypted key
```
sudo vi /etc/postgresql/<version>/main/pg_hba.conf
```
* edit config file like this
```
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
host all all :/0 md5
```
* restart PostgreSQL to enable the changes
```
sudo systemctl restart postgresql
systemctl status postgresql
```
# Disable Start Up At System Boot
* If you install the PostgreSQL database from packages, it is automatically added to the start up scripts of the operating system. If you are only learning to work with the database, it is unnecessary to start the database each time you boot the system. Remove system startup link for the PostgreSQL database
```
sudo update-rc.d -f postgresql remove
```
# Links
* [PostgreSQL Java](https://zetcode.com/java/postgresql/)
* OPTION: disable start up at system boot like [this](./postgres-boot-startup-disable.md)