From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Forcibly disconnect users from one database |
Date: | 2020-04-10 22:39:58 |
Message-ID: | fe62a3fb-3b11-8b50-1654-9d50425adee2@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 4/10/20 1:20 PM, Andrus wrote:
> Hi!
>
> Postgres 12 does not allow to drop database if it is in use. DROP
> DATABASE throws error:
>
> postgres(at)template1 ERROR: database "mydb" is being accessed by other users
> postgres(at)template1 DETAIL: There is 1 other session using the database.
> postgres(at)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 ?
Find backends:
https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
Kill backends:
https://www.postgresql.org/docs/12/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL
>
> Andrus.
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Andrus | 2020-04-11 21:25:08 | Which commands are guaranteed to drop role |
Previous Message | Stephen Frost | 2020-04-10 20:37:46 | Re: Using of --data-checksums |