2
I need to set up a new PostgreSQL database for my Django project.
Loading...
Q&A · Answered
I need to set up a new PostgreSQL database for my Django project.
Accepted answer
# Login to PostgreSQL
sudo -u postgres psql
# Create database
CREATE DATABASE myproject_db;
# Create user
CREATE USER myproject_user WITH PASSWORD 'secure_password';
# Grant privileges
GRANT ALL PRIVILEGES ON DATABASE myproject_db TO myproject_user;
# For Django
ALTER ROLE myproject_user SET client_encoding TO 'utf8';
ALTER ROLE myproject_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE myproject_user SET timezone TO 'UTC';
\qSay what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.