0

I have a Django project I am trying to set up on Ubuntu and am creating a new database in PostgreSQL 14.

The default root user is Postgres as usual.

Then I tried creating a new user with my Linux username "abc" with all the privileges: "SUPERUSER", "CREATEDB", etc. Everything worked fine and a new user was created.

And it was suggested that I create a database with the same name "abc".

So, I did CREATE DATABASE abc; in the psql shell, it gives no error and results in nothing.

I tried createdb abc or creatdb in the bash terminal but this also does nothing either.

The solution from this SO answer link does not work for me at all.

I also tried this which did not do anything.

I ultimately just want to be able to create the database for my Django project, which I am not able to do, and I have now no clue what I am doing wrong.

Here's the command I am using to set up the Django project db:

# create new user who will be the db owner
# on Ubuntu, root user is postgres
createuser -P <new_user_name> -U <root_user>

# if you're having issues logging in
# see https://stackoverflow.com/a/18664239/3187043

# create new db with the above created user as its owner
createdb -E UTF8 --lc-collate=en_IN.UTF-8 --lc-ctype=en_IN.UTF-8 -T template0 -O <new_user_name> -U <root_user> <new_db_name>
# this doesn't get created

# copy the contents to your new db
psql -U <new_user_name> <new_db_name> < ~/Downloads/backup-ocrdb-2018-09-13_1214.psql
#fails with no output

# Log in to psql console using
psql -U <new_user_name> <new_db_name>
#unable to login because db has not been created

As suggested by @Laurenz Albe

Here is the output of running : SELECT * FROM pg_locks;

enter image description here

Singh
  • 504
  • 4
  • 15

0 Answers0