Postgresql page

This commit is contained in:
Edgar P. Burkhart 2022-08-22 18:43:36 +02:00
parent c519755ae9
commit b574e9f07b
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -0,0 +1,51 @@
---
title: "Postgresql"
weight: 1
# bookFlatSection: false
# bookToc: true
# bookHidden: false
# bookCollapseSection: false
# bookComments: false
# bookSearchExclude: false
---
# Postgresql
*On this page, `$` means the command must be run as a user with adequate rights such as the `postgresql` user.*
## Filesystem preparation
In case a Btrfs filesystem is used, Copy-on-Write should be disabled first.
## Initial setup
The database can be initialized using the following command. Locale defaults to current environment locale.
```
$ initdb --locale C.UTF-8 --encoding=UTF8 -D /var/lib/postgres/data --data-checksums
```
Postgresql can then be started using the `postgresql` systemd service.
## Usage
### Creating users
The following command can be used:
```
$ createuser [--interactive]
```
Additionnal options can be used to give permissions to the user (usually not needed).
Users can be deleted using the following command:
```
$ dropuser [-i/--interactive] [user]
```
### Creating databases
The following command can be used:
```
$ createdb [-O owner] [dbname [description]]
```
## Sources
1. <https://wiki.archlinux.org/title/PostgreSQL>