not able to delete database in postgres

687 Views Asked by At

enter image description here

The drop database command is not working in sql shell. It shows db doesn't exists. But pgadmin and \l shows the db. What is the problem and how to delete the db?

2

There are 2 best solutions below

1
Omri On BEST ANSWER

Try writing "myDatabase" (with quotation marks "") since your name is case-sensitive. In general it is better to use lower-case names in postgres and I think in unix in general.

0
Amina K M On

1.find . -path "/migrations/.py" -not -name "init.py" -delete

2.find . -path "/migrations/.pyc" -delete [Instead of first 2 steps,you can manually deleting all the files except init.py from migrations folder in all app.]

3.sudo su postgres

4.psql

  1. DROP DATABASE databasename;

6.\q

7.createdb databasename

8.psql

9.grant all privileges on database databasename to username;

10.\q

11.exit

12.source venv/bin/activate

13.python manage.py makemigrations

14.python manage.py migrate

  1. python manage.py createsuperuser

  2. python manage.py runserver