From: Andrus <kobruleht2@hot.ee>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Forcibly disconnect users from one database
Date: Fri, 10 Apr 2020 23:20:04 +0300
Message-ID: <1C5A3D61BBBE42A38C61C436AEF3C20E@dell2> (raw)
Hi!
Postgres 12 does not allow to drop database if it is in use. DROP DATABASE throws error:
postgres@template1 ERROR: database "mydb" is being accessed by other users
postgres@template1 DETAIL: There is 1 other session using the database.
postgres@template1 STATEMENT: DROP DATABASE "mydb"
How to disconnect all users from database?
Using
/etc/init.d/postgresql restart
disconnects users from all databases. How to disconnect users from one database only ?
I looked into pgAdmin 4 but havent found such command.
pgAdmin 3 had buttons to select kill processes by database name but those disappeared in pgAdmin 4.
How to find which users are using database and forcibly disconnect them ?
Andrus.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: kobruleht2@hot.ee
Subject: Re: Forcibly disconnect users from one database
In-Reply-To: <1C5A3D61BBBE42A38C61C436AEF3C20E@dell2>
References: <1C5A3D61BBBE42A38C61C436AEF3C20E@dell2>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox