postgresql 删除其他用户正在访问的数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/664091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:40:16  来源:igfitidea点击:

Drop a database being accessed by another users?

databasepostgresql

提问by josernestodavila

I'm trying to drop a database from PgAdmin 3 and I get this error message:

我正在尝试从 PgAdmin 3 中删除数据库,但收到此错误消息:

ERROR: can't delete current database
SQL state: 55006

how can I force the delete/fix this error, of this database?

如何强制删除/修复此数据库的此错误?

回答by danieltalsky

Quick fix in PgAdmin: just create another empty database. Select it. Delete the first one. Voila.

PgAdmin 中的快速修复:只需创建另一个空数据库。选择它。删除第一个。瞧。

You can also connect to the command line without selecting a specific database, and drop your database.

您还可以在不选择特定数据库的情况下连接到命令行,然后删除您的数据库。

The problem here is not that other usersare connected to the database, but that youare.

这里的问题不是其他用户连接到数据库,而是连接到数据库。

回答by klaxon

Simplest fix for this is restart the postgresql. After that You can get rid of database!

最简单的解决方法是重新启动 postgresql。之后你可以摆脱数据库!

回答by klaxon

Instead of creating new database he can simply connect to postgres database, which is created by default in all new PostgreSQL installations. And even if it is not there - template1 should be always there.

他可以简单地连接到 postgres 数据库,而不是创建新的数据库,该数据库在所有新的 PostgreSQL 安装中默认创建。即使它不存在 - template1 也应该始终存在。

回答by Maninder

The best method to drop user is below mentioned

删除用户的最佳方法如下所述

Like i have a user name is "X" and it have access permission to database name : "Test" . And now we are created connection with "Test" database

就像我有一个用户名是“X”,它有对数据库名称的访问权限:“Test”。现在我们创建了与“Test”数据库的连接

If we try: drop user "X" this will be definality show below mentioned error:

如果我们尝试:删除用户“X”,这将是终止显示下面提到的错误:

ERROR: user "X" cannot be dropped because the user has a privilege on some object SQL State=55006

错误:无法删除用户“X”,因为该用户对某个对象具有权限 SQL State=55006

First of all connection should not be created with "Test" db.because it currently use so we are not able to delete the user. create connection with any of database except eg "Test" Now again try drop user test It should be worked fine on my side,let me know if you are facing issue on your side

首先,不应使用“Test”db 创建连接。因为它当前正在使用,所以我们无法删除用户。创建与任何数据库的连接,例如“测试”现在再次尝试删除用户测试它应该在我这边工作正常,如果您遇到问题,请告诉我