... | ... | @@ -15,17 +15,13 @@ This page will tell you the short and to the point stuff you need to know about |
|
|
Easiest is using docker for that:
|
|
|
|
|
|
1. Install docker on your local machine: E.g. on [Windows](https://docs.docker.com/desktop/install/windows-install/) or on [Linux Ubuntu](https://docs.docker.com/engine/install/ubuntu/).
|
|
|
2. To start execute command: `docker run -p 5432:5432 --name wyatt_local_db -e POSTGRES_USER=wyatt -e POSTGRES_PASSWORD=somepasswd -e POSTGRES_DB=wyatt -d postgres:15.4`
|
|
|
2. To start execute command: `docker run -p 5432:5432 --name local_db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=somepasswd -e POSTGRES_DB=postgres -d postgres:16.2`
|
|
|
3. To restart: `docker start wyatt_local_db` (on Windows this can be done in app **Docker Desktop**).
|
|
|
|
|
|
|
|
|
# 2. Passwords
|
|
|
|
|
|
There are many ways to use a password. For using DB commands from the command line (e.g. from scripts) the preferred way is to add credentials file `~/.pgpass`. This is how you can do that on a container (which for us is the most common approach). This is the script for a container called `wyatt_local_db` where the DB runs on `localhost:5432`, with a DB and user called `wyatt`:
|
|
|
|
|
|
```bash
|
|
|
docker exec -t wyatt_local_db bash -c 'echo "localhost:5432:wyatt:wyatt:somepasswd" > ~/.pgpass && chmod 0600 ~/.pgpass'
|
|
|
```
|
|
|
There are many ways to use a password. For using DB commands from the command line (e.g. from scripts) the preferred way is to add credentials file `~/.pgpass`. The [db-set-pass](https://gitlab.xlrit.com/xlrit/gears/scripts/-/blob/main/db-set-pass) script will do that for you.
|
|
|
|
|
|
# 3. Interact with DB
|
|
|
|
... | ... | |