PostgreSQL tutorials for having a quick dev setup that just works are overcomplicated. Here's what you should do in 99.99% of cases.
root# apt install postgresql
As your main user:
antoine$ sudo -u postgres createuser -dP $USER
-d
to allow database creation, -P
to prompt for a password. The first argument is your UNIX username.
As your main user:
antoine$ createdb mydb
That's it. No pg_hba.conf
, no CREATE ROLE
, no WITH ENCRYPTED
, no ALTER USER
.
antoine$ psql mydb
No password to enter.
With Django:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydb',
}
}
No password either. The only reason for having a password at all is just to be able to log in remotely or for tools that don't handle peer auth.