capsula-gemini/source/notes/postgres.gmi

56 lines
787 B
Plaintext
Raw Normal View History

2021-08-28 23:13:02 -05:00
## Postgres
2022-02-10 22:44:33 -06:00
* Instalar
2021-08-28 23:13:02 -05:00
```Instalar
sudo apt install postgresql
2021-09-12 22:59:41 -05:00
2021-08-28 23:13:02 -05:00
```
2022-02-10 22:44:33 -06:00
* Configurar acceso
2021-08-28 23:13:02 -05:00
```Configurar acceso
sudo vim /etc/postgresql/12/main/pg_hba.conf
local all postgres trust
local all all scram-sha-256
sudo systemctl restart postgresql
2021-09-12 22:59:41 -05:00
2021-08-28 23:13:02 -05:00
```
2022-02-10 22:44:33 -06:00
* Crear roles y bases de datos
2021-08-28 23:13:02 -05:00
```
psql -U postgres
2021-09-06 23:11:53 -05:00
create role ROLE_NAME with login encrypted password 'CONTRASEÑA';
2021-08-28 23:13:02 -05:00
create database NAME with owner ROLE_NAME;
2021-09-12 22:59:41 -05:00
2021-08-28 23:13:02 -05:00
```
2022-02-10 22:44:33 -06:00
* Generar respaldo de una base de datos.
```
pg_dump -U postgres -d DATA_BASE -Fc -f NAME.bk
```
* Restaurar base de datos desde respaldo.
```
pg_restore -U postgres -d DATA_BASE NAME.bk
```
2021-08-28 23:13:02 -05:00
=> gemini://elmau.net/chuletas.gmi Regresar el índice
=> gemini://elmau.net Regresar el inicio