> Markdown version of https://yucca.app/en/docs/guides/DB/postgres/. Documentation index: [llms.txt](https://yucca.app/en/llms.txt), full text in one file: [llms-full.txt](https://yucca.app/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# Installing Postgres

> **Info.** If you need help from a specialist to solve this or any other issue, check out our **[technical support](https://yucca.app/en/docs/support.md)** 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**
>
> ```bash
> 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.

```bash
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:

```bash
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](https://yucca.app/en/docs/configuration.md#type) parameter, along with the rest of the connection details:

* [database.host](https://yucca.app/en/docs/configuration.md#host)
* [database.name](https://yucca.app/en/docs/configuration.md#name)
* [database.user](https://yucca.app/en/docs/configuration.md#user)
* [database.password](https://yucca.app/en/docs/configuration.md#database-password)

Example of the final configuration via file:

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

```

Restart the server:

```bash
sudo systemctl restart yucca

```

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

```bash
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
...

```
