# install brew install postgresql@14 # run server pg_ctl -D /opt/homebrew/var/postgresql@14 start # open database psql # open database with specific user name psql postgres -U # (inside db) # create new user with login permission CREATE ROLE WITH LOGIN; # add create db permission ALTER ROLE CREATEDB; # list user \du # quit \q # create database CREATE DATABASE ; # drop db DROP DATABASE ; # grant permission to user GRANT ALL PRIVILEGES ON DATABASE TO ; # list all database \list # connect specific database in postgres database \c # list all table \dt # .env for node.js PG_CONNECTION_STRING=postgres://myuser@localhost/mydatabase # backup pg_dump "postgresql://myuser:mypassword@localhost:5432/mydb" > backup.sql # restore psql -U -d < .sql