# PostgreSQL

### Install

Install postgresql and postgis for coordinates data

```bash
sudo apt install postgresql postgis -y
```

### Login

```bash
sudo -u postgres psql
```

### Change password to default account

```sql
ALTER USER postgres WITH PASSWORD 'new password';
```

### Restrict remote access to localhost only

Open the config file

```bash
nano /etc/postgresql/15/main/postgresql.conf
```

uncomment this line

```ini
listen_addresses = 'localhost'
```

if you need remote access

```ini
listen_addresses = '0.0.0.0'
```

and Edit `/etc/postgresql/15/main/pg_hba.conf` and add a line like:

```ini
host    all             all             192.168.1.0/24          scram-sha-256
```