Install PostgreSQL:
sudo apt install postgresql postgresql-contrib
Start PostgreSQL:
sudo systemctl start postgresql.service
Check if PostgreSQL is running
sudo service postgresql status
Start the Postgres prompt
sudo -u postgres psql
- Run these commands inside PostgreSQL to create a database + user:
CREATE DATABASE databasename;
CREATE USER user WITH ENCRYPTED PASSWORD 'password';
ALTER ROLE user SET client_encoding TO 'utf8';
ALTER ROLE user SET default_transaction_isolation TO 'read committed';
ALTER ROLE user SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE databasename TO user;
\c <database_name> postgres
GRANT ALL PRIVILEGES ON SCHEMA public TO <username>;
Exit PostgreSQL: \q
DATABASE_URL="postgresql://<username>:<password>@localhost:5432/<database_name>?schema=public"