postgres=# drop database k8s_kong;

ERROR: database "k8s_kong" is being accessed by other users

DETAIL: There are 24 other sessions using the database.

说明该k8s_kong库正在被人连接。解决方法是:

查询出连接该数据库的进程,并将其杀死(比较暴力)

postgres=# select pg_terminate_backend(pid) from pg_stat_activity where DATNAME = 'k8s_kong';

ERROR: must be a member of the role whose process is being terminated or member of pg_signal_backend

postgres=# grant pg_signal_backend to pointsmart_ops;   给用户授权pg_signal_backend角色,不然没权限执行不了下一步

Command OK

postgres=# select pg_terminate_backend(pid) from pg_stat_activity where DATNAME = 'k8s_kong';

+----------------------+

| pg_terminate_backend |

+----------------------+

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

| t |

+----------------------+

24 rows in set

postgres=# drop database k8s_kong;

Command OK

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐