# Postgresql install and set-up

## Ubuntu

Main instructions: [here](https://www.postgresql.org/download/linux/ubuntu/)

```bash
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
```

## Create user `kms` and database `kms`

1. Connect to psql under user `postgres`

    ```sh
    sudo -u postgres psql
    ```

2. Create user `kms` with password `kms`

    ```sh
    create user kms with encrypted password 'kms';
    ```

    The password can obviously be set to any other appropriate value

3. Create database `kms` under owner `kms`

    ```sh
    create database kms owner=kms;
    ```

4. Connection `POSTGRES_URL`

    Assuming a server running on localhost, the connection URL will be

    ```sh
    POSTGRES_URL=CONNECTION=postgresql://kms:kms@127.0.0.1:5432:kms
    ```
