Postgres drop database error: pq: cannot drop the currently open database

后端 未结 4 981
别那么骄傲
别那么骄傲 2021-02-05 01:21

I\'m trying to drop the database I\'m currently connected to like so, but I\'m getting this error:

pq: cannot drop the currently open database

4条回答
  •  借酒劲吻你
    2021-02-05 02:00

    None of this worked for me since I tried to do it through pgAdmin which kept database connections open as soon as I delete them.

    Solution:

    C:\Program Files\PostgreSQL\11\scripts\runpsql.bat
    

    after you supply correct information you will be able to get pg command prompt, here you can just type:

    dbdrop yourdatabase
    

    After that you might still see database in pgAdmin but now you can just simply delete it with right click and DELETE/DROP option.

提交回复
热议问题