52 lines
1.1 KiB
Markdown
52 lines
1.1 KiB
Markdown
|
---
|
||
|
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>
|