Skip to main content

Installing Postgres

info

If you need help from a specialist to solve this or any other issue, check out our technical support terms

There are many ways to install the PostgreSQL DBMS; we'll describe 2 that, in our opinion, are the simplest and quickest. You need to choose the one that suits you best.

warning

The examples use a simple password – you should change it!

Installing PostgreSQL from packages on the host

For installation, use the official instructions on the developer's website https://www.postgresql.org/download/

Quick installation on Debian or Ubuntu
sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt install postgresql-14 -y

After installing and starting it, you need to create a database and a role to connect with.

sudo -u postgres psql -c "CREATE DATABASE yucca;"
sudo -u postgres psql -c "CREATE USER postgres WITH PASSWORD 'postgres';"
sudo -u postgres psql -c 'GRANT ALL PRIVILEGES ON DATABASE yucca TO postgres;'

Installing PostgreSQL in Docker

Run the official container with the required parameters:

docker run -d \
--name yucca-postgres \
--net host \
--restart always \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=yucca \
postgres:14.4-alpine

Configuring Yucca's connection to the Postgres database

Specify the postgres type in the database.type parameter, along with the rest of the connection details:

Example of the final configuration via file:

[database]
host = "127.0.0.1:5432"
name = "yucca"
password = "postgres"
type = "postgres"
user = "postgres"

Restart the server:

sudo systemctl restart yucca

Upon a successful connection, you should see log messages (debug tab) similar to the following:

sudo journalctl -o short --no-pager -n 100 -f -u yucca | grep "ORM"
...
2022-08-12T12:10:44.865+0500 DEBUG server/server.go:366 postgres ORM engine initialization successful
...