{"id":812,"date":"2021-11-13T17:45:00","date_gmt":"2021-11-13T11:45:00","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=812"},"modified":"2021-11-13T17:45:00","modified_gmt":"2021-11-13T11:45:00","slug":"error-cannot-drop-the-currently-open-database-postgresql","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/error-cannot-drop-the-currently-open-database-postgresql.html","title":{"rendered":"ERROR: cannot drop the currently open database &#8211; PostgreSQL"},"content":{"rendered":"\n<p>If you are trying to drop a database and getting an error like the following in PostgreSQL:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ERROR: cannot drop the currently open database<\/pre>\n\n\n\n<p>Then, the easiest technique to solve the problem is to restart your PostgreSQL server. I am using PGSQL 9.6, here was my command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl stop postgresql-9.6.service\nsystemctl start postgresql-9.6.service<\/pre>\n\n\n\n<p>If you are using PostgreSQL 13 or above, you have an option to drop the database with force now. You may drop the database using the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DROP DATABASE database_to_drop WITH (FORCE);<\/pre>\n\n\n\n<p>Replace &#8216;database_to_drop&#8217; with the database you would like to drop.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are trying to drop a database and getting an error like the following in PostgreSQL: Then, the easiest technique to solve the problem is to restart your PostgreSQL server. I am using PGSQL 9.6, here was my command: If you are using PostgreSQL 13 or above, you have an option to drop the &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/error-cannot-drop-the-currently-open-database-postgresql.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ERROR: cannot drop the currently open database &#8211; PostgreSQL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[412,523],"tags":[414,605,524],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/812"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":813,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/812\/revisions\/813"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}