# How to install PostgreSQL - Ubuntu 24

## 📌 1. Install PostgreSQL

Update packages and install PostgreSQL server:

```plaintext
sudo apt update && sudo apt upgrade -y
```

Install PostgreSQL server

```plaintext
sudo apt install postgresql postgresql-contrib -y
```

Check if the service is active:

```plaintext
sudo systemctl status postgresql
```

## 📌 2. Create a new database and change user password

Switch to the administrative `postgres` user:

```plaintext
sudo -i -u postgres
```

Open the PostgreSQL prompt:

```plaintext
psql
```

Now execute the SQL commands:

```plaintext
-- Create database
CREATE DATABASE n8n_db;

-- Change postgres user password
ALTER USER postgres PASSWORD 'your_new_password';


-- Grant permissions to the user on the database
GRANT ALL PRIVILEGES ON DATABASE n8n_db TO postgres;
```
