# Database setup Krenalis uses [PostgreSQL](https://www.postgresql.org/) 14 or later as its internal database. PostgreSQL database stores only Krenalis's operational and system data, never contains any customer information. You can configure the data warehouse where customer data are stored when creating a workspace. > If you are [running Krenalis via Docker Compose](https://www.krenalis.com/docs/installation/using-docker-compose.md), it includes a PostgreSQL image, and the setup is handled automatically. This page instead documents the case where you are installing Krenalis from source code and want to use your own PostgreSQL instance. ### 1. Create a database Create a PostgreSQL database that will be used by Krenalis. In this example, we'll name the database _krenalis_: ```sh psql postgres -c "CREATE DATABASE " ``` Replace `` with a database name, you can choose any name you like for the database. ### 2. Configure environment variables Generate a KMS master key for Krenalis and keep it in a safe place: #### Linux and macOS ```sh head -c 32 /dev/urandom | base64 ``` #### Windows ```powershell $bytes = New-Object byte[] 32 [System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes) [Convert]::ToBase64String($bytes) ``` Then prepare a `.env` file in the same directory as the Krenalis executable, and add the generated value together with the PostgreSQL settings: ```sh KRENALIS_KMS=key: KRENALIS_DB_HOST= KRENALIS_DB_PORT=5432 KRENALIS_DB_USERNAME= KRENALIS_DB_PASSWORD= KRENALIS_DB_DATABASE= KRENALIS_DB_SCHEMA=public ``` Replace `` with the generated KMS key. Replace the placeholder values (``, ``, ``, and ``) with the PostgreSQL connection details for the database you created in step 1. The values for `KRENALIS_DB_PORT` and `KRENALIS_DB_SCHEMA` are set to PostgreSQL's defaults. You only need to change them if your installation uses a custom port or schema. Do not change `KRENALIS_KMS` for an installation that is already in use. The database tables will be created on the first startup of Krenalis, as described later. ## Next steps * Event streaming setup. Configure NATS which Krenalis uses as its primary database to store metadata, configuration, and operational state.