diff --git a/doc/postgres-boot-startup-disable.md b/doc/postgres-boot-startup-disable.md new file mode 100644 index 0000000..a2c081e --- /dev/null +++ b/doc/postgres-boot-startup-disable.md @@ -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 +``` + diff --git a/doc/postgres-connect-remote.md b/doc/postgres-connect-remote.md new file mode 100644 index 0000000..7c3bc43 --- /dev/null +++ b/doc/postgres-connect-remote.md @@ -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//main/postgresql.conf /etc/postgresql//main/postgresql.conf-backup +``` + +* open config file to define what IP addresses postgres to listen on +``` +sudo vi /etc/postgresql//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//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 +``` diff --git a/doc/postgres.md b/doc/postgres.md index bbc63fb..5e614a5 100644 --- a/doc/postgres.md +++ b/doc/postgres.md @@ -6,7 +6,7 @@ NOTE: Insert the postgresql version that is running on the respective host ``` cd /etc/postgresql//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//main/postgresql.conf /etc/postgresql//main/postgresql.conf-backup -``` - -* open config file to define what IP addresses postgres to listen on -``` -sudo vi /etc/postgresql//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//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)