Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jN08W-0002Oo-TM for pgsql-general@arkaria.postgresql.org; Fri, 10 Apr 2020 20:20:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jN08V-0005IF-QF for pgsql-general@arkaria.postgresql.org; Fri, 10 Apr 2020 20:20:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jN08V-00058O-In for pgsql-general@lists.postgresql.org; Fri, 10 Apr 2020 20:20:23 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jN08S-0000HX-7h for pgsql-general@postgresql.org; Fri, 10 Apr 2020 20:20:22 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 71A641BDB for ; Fri, 10 Apr 2020 23:20:17 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AUZWUySNYXqn for ; Fri, 10 Apr 2020 23:20:15 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost2.estpak.ee [213.180.2.80]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 3FD7B1BA8 for ; Fri, 10 Apr 2020 23:20:15 +0300 (EEST) Received: from dell2 (82.131.71.142.cable.starman.ee [82.131.71.142]) (Authenticated sender: kobruleht2) by HOT-Relayhost2.estpak.ee (Postfix) with ESMTPSA id 48zTsC1GCZz35P for ; Fri, 10 Apr 2020 23:20:13 +0300 (EEST) Message-ID: <1C5A3D61BBBE42A38C61C436AEF3C20E@dell2> From: "Andrus" To: "pgsql-general" Subject: Forcibly disconnect users from one database Date: Fri, 10 Apr 2020 23:20:04 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="windows-1257"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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.