PostgreSQL

PostgreSQL documentation

www.postgresql.org

Windows:

Installation:

1. Download the installation file.
2. Install the database
PostgreSQL Server
Command Line Tools
PG Admin (for easy access to the database)
The database has been installed and is now available without any specific configuration.

Creating a new database

1. Open the pgAdmin.
2. Select the server on which you want to add a new database.
3. Right-click on the server.
4. Click on Create database.
Another window opens in which you can configure your database.
You have created a new database.

Settings for access via the network

1. Use a text editor to open the file pg_hba.config in C:\Program Files\PostgreSQL\*version*\data\
2. Adjust the entry host all all 127.0.0.1/32 scram-sha-256 or add a new one.
By default, 127.0.0.1/32 is entered as local only. If other systems are to have access to the database, the corresponding IP address must be set.
3. Configure your firewall according to the port selected during installation (default: 5432/tcp).
Thanks to the new configuration, your database is now accessible over the network.

TwinCAT/BSD

Installation

Connect to the FreeBSD® PackageManager to install the appropriate package.
1. Open the configuration file "FreeBSD.conf".
doas ee /usr/local/etc/pkg/repos/FreeBSD.conf
2. Change the value "enabled" to yes.
3. Perform an update of the packages.
doas pkg update
You will now see the available FreeBSD packages.
4. Install the PostgreSQL database server.
doas pkg install xxxx
5. Enable the PostgreSQL service.
doas sysrc postgresql_enable="YES"
The database has been successfully installed and the service has been set up in the autostart.

Creating a new database

1. Initialize the database.
doas /usr/local/etc/rc.d/postgresql initdb
2. Start the database service.
doas service postgresql start
3. Set a password for the default user.
doas passwd postgres
The database has been successfully initialized and started.

Settings for access via the network

1. Open pf.conf to configure the firewall.
doas ee /etc/pf.conf
2. Add the port 5432.
pass in quick proto tcp to port 5432 keep state
3. Save and exit the editor.
4. Reload the firewall configuration.
doas pfctl -f /etc/pf.conf
Port 5432 has been opened in the firewall.
5. Open postgresql.conf to adjust "listen_addresses".
doas ee /var/db/postgres/data17/postgresql.conf
6. Change the entry listen_addresses to '*'.
7. Save and exit the editor.
8. Open pg_hba.conf to adjust the security settings.
doas ee /var/db/postgres/data17/pg_hba.conf
9. Adjust the entry host all all 127.0.0.1/32 or add a new one. Change the method to md5.
By default, 127.0.0.1/32 is entered as local only. If other systems are to have access to the database, the corresponding IP address must be set.
# TYPE  DATABASE        USER            ADDRESS                  METHOD
# "local" is for Unix domain socket connections only
local   all             all                                      md5
# IPv4 local connections:
host    all             all             127.0.0.1/32             md5
# IPv6 local connections:
host    all             all             ::1/128                  md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                      md5
host    replication     all             127.0.0.1/32             md5
host    replication     all             ::1/128                  md5
10. Save and exit the editor.
11. Restart the service.
doas service postgresql restart
Thanks to the new configuration, your database is now accessible over the network.