8c6a83c987c82b72ee7a5366e518322ab8c396cb
[webi-installers/.git] / postgres / README.md
1 ---
2 title: Postgres
3 homepage: https://www.postgresql.org/
4 tagline: |
5   PostgreSQL: The World's Most Advanced Open Source Relational Database.
6 ---
7
8 ## Updating `postgres`
9
10 ```bash
11 webi postgres@stable
12 ```
13
14 Use `@x.y.z` for a specific version.
15
16 ## Cheat Sheet
17
18 > Postgres is the all-in-one database for beginners and experts alike. It
19 > handles SQL, 'NoSQL', JSON, HSTORE, Full-Text Search, Messages Queues and
20 > more. Best bang for buck.
21
22 ### Start the postgres server
23
24 Run just once (for development):
25
26 ```bash
27 postgres -D $HOME/.local/share/postgres/var -p 5432
28 ```
29
30 Run as a system service on Linux:
31
32 ```bash
33 sudo env PATH="$PATH" \
34     serviceman add --system --username $(whoami) --name postgres -- \
35     postgres -D "$HOME/.local/share/postgres/var" -p 5432
36 ```
37
38 ### Connect with the psql client
39
40 ```bash
41 psql 'postgres://postgres:postgres@localhost:5432/postgres'
42 ```
43
44 ### Initialize a database with a password
45
46 ```bash
47 echo "postgres" > /tmp/pwfile
48 mkdir -p $HOME/.local/share/postgres/var/
49
50 initdb -D $HOME/.local/share/postgres/var/ \
51     --username postgres --pwfile "/tmp/pwfile" \
52     --auth-local=password --auth-host=password
53
54 rm /tmp/pwfile
55 ```