Install PostgreSQL

# pkg_add postgresql-server
quirks-3.124 signed on 2019-04-15T12:10:16Z
postgresql-server-11.2p1: ok
The following new rcscripts were installed: /etc/rc.d/postgresql
See rcctl(8) for details.
New and changed readme(s):
        /usr/local/share/doc/pkg-readmes/postgresql-server
# su - _postgresql
$ mkdir /var/postgresql/data
$ initdb -D /var/postgresql/data -U postgres \
-A scram-sha-256 -E UTF8 -W
# rcctl start postgresql
postgresql(ok)
# psql postgres postgres
Password for user postgres:
psql (11.2)
Type "help" for help.

postgres=# CREATE DATABASE db;
CREATE DATABASE
postgres=# CREATE USER user WITH ENCRYPTED PASSWORD 'pwd';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE db TO user;
GRANT
postgres=# exit
# psql db user
Password for user user:
psql (11.2)
Type "help" for help.

user=> exit
#

© RGZ.EE OÜ