Learnings from setting up Postgres on a DigitalOcean droplet for Penultimate Guitar. This was done on trackstar-22, so should presumably work on any Ubuntu 22.04 instance.
- Install postgres. This will add a
postgresuser account to the system. I set up another user account to interact with the database, in this case called
psql, create a database that will be used for your application.
- Whiler running
\passwordand set a password for this account to interact with Postgres. This password should not use an
@, as it will conflict with the connection string later.
Grant the user account access to the database with the SQL command.
GRANT ALL PRIVILEGES ON DATABASE "my_db" to my_user;
/etc/postgresql/14/main/pg_hba.conf(or equivalent). Set the
ADDRESSfield for IPv4 connections to this:
# IPv4 local connections: host all all 0.0.0.0/0 scram-sha-256
# - Connection Settings - listen_addresses = '*'
systemctl restart postgres
In the Prisma application, set up Prisma normally. The connection string in
.envshould be this format:
Push the schema designed in
prisma/schema.prismausing the command
npx prisma db push.
- If this succeed, Prisma can now effectively connect to the database!