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

8
  • Must be a typo. Commented Nov 30, 2021 at 6:58
  • I have done it a lot of time, I dont think it will be due to a typo. Commented Nov 30, 2021 at 7:07
  • Maybe it's a Windows problem because I m doing it inside WSL2. Commented Nov 30, 2021 at 7:08
  • 1
    If it hangs and does not finish, that sounds like a lock. Look at the PostgreSQL log for interesting messages. While CREATE DATABASE hangs, run SELECT * FROM pg_locks; in a second database session and add the result to the question. Commented Nov 30, 2021 at 7:21
  • 1
    Did you try what I recommended? Commented Nov 30, 2021 at 8:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.