Django Cannot Create Test Database Permission Denied

8,177

you user probably does not have permission to create a database, open a terminal and log into postgress as postgress and run the following

ALTER USER user CREATEDB;
Share:
8,177

Related videos on Youtube

SidC
Author by

SidC

Desktop, web, business intelligence and mobile developer.

Updated on September 18, 2022

Comments

  • SidC
    SidC almost 2 years

    I'm running Ubuntu 14.04 with Postgres 9.3, Python 3.0 and Django 1.7. When I try to debug my application from PyDev, I receive the following:

    Creating test database for alias 'default'...
    Got an error creating the test database: permission denied to create database
    

    Oddly enough, I cannot login to user postgres from command line with the password originally created. I reset it once last night, and am still unable to do so.

    My pg_hba.conf is as follows:

    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    # IPv6 local connections:
    host    all             all             ::1/128                 md5
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    #local   replication     postgres                                peer
    #host    replication     postgres        127.0.0.1/32            md5
    #host    replication     postgres        ::1/128                 md5
    local all postgres peer
    local all stbiuser md5
    local all all md5
    

    My settings.py is as follows:

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'db',
        'USER': 'user',
        'PASSWORD': 'mypass',
        'Host':'127.0.0.1',
        'PORT':'5432'
        }
    }
    

    How do I remedy the permission denied message? Are there any settings modifications that are required as well?

    • don.joey
      don.joey over 9 years
      Can you try local all postgres all?